mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2025-12-05 23:34:45 +00:00
chore: refactors downloadCLI
see: -https://github.com/opentofu/setup-opentofu/pull/2#discussion_r1356503597 - https://github.com/opentofu/setup-opentofu/pull/2#discussion_r1356504741 Signed-off-by: Dmitry Kisler <admin@dkisler.com>
This commit is contained in:
parent
ff4f92709b
commit
6196ddd9f5
2 changed files with 18 additions and 10 deletions
14
dist/index.js
vendored
14
dist/index.js
vendored
|
|
@ -145,11 +145,15 @@ function mapOS (os) {
|
|||
return os;
|
||||
}
|
||||
|
||||
async function downloadCLI (url) {
|
||||
async function downloadAndExtractCLI (url) {
|
||||
core.debug(`Downloading OpenTofu CLI from ${url}`);
|
||||
const pathToCLIZip = await tc.downloadTool(url);
|
||||
|
||||
let pathToCLI = '';
|
||||
if (!pathToCLIZip) {
|
||||
throw new Error(`Unable to download OpenTofu from ${url}`);
|
||||
}
|
||||
|
||||
let pathToCLI;
|
||||
|
||||
core.debug('Extracting OpenTofu CLI zip file');
|
||||
if (os.platform().startsWith('win')) {
|
||||
|
|
@ -164,8 +168,8 @@ async function downloadCLI (url) {
|
|||
|
||||
core.debug(`OpenTofu CLI path is ${pathToCLI}.`);
|
||||
|
||||
if (!pathToCLIZip || !pathToCLI) {
|
||||
throw new Error(`Unable to download OpenTofu from ${url}`);
|
||||
if (!pathToCLI) {
|
||||
throw new Error('Unable to unzip OpenTofu');
|
||||
}
|
||||
|
||||
return pathToCLI;
|
||||
|
|
@ -254,7 +258,7 @@ async function run () {
|
|||
}
|
||||
|
||||
// Download requested version
|
||||
const pathToCLI = await downloadCLI(build.url);
|
||||
const pathToCLI = await downloadAndExtractCLI(build.url);
|
||||
|
||||
// Install our wrapper
|
||||
if (wrapper) {
|
||||
|
|
|
|||
|
|
@ -34,11 +34,15 @@ function mapOS (os) {
|
|||
return os;
|
||||
}
|
||||
|
||||
async function downloadCLI (url) {
|
||||
async function downloadAndExtractCLI (url) {
|
||||
core.debug(`Downloading OpenTofu CLI from ${url}`);
|
||||
const pathToCLIZip = await tc.downloadTool(url);
|
||||
|
||||
let pathToCLI = '';
|
||||
if (!pathToCLIZip) {
|
||||
throw new Error(`Unable to download OpenTofu from ${url}`);
|
||||
}
|
||||
|
||||
let pathToCLI;
|
||||
|
||||
core.debug('Extracting OpenTofu CLI zip file');
|
||||
if (os.platform().startsWith('win')) {
|
||||
|
|
@ -53,8 +57,8 @@ async function downloadCLI (url) {
|
|||
|
||||
core.debug(`OpenTofu CLI path is ${pathToCLI}.`);
|
||||
|
||||
if (!pathToCLIZip || !pathToCLI) {
|
||||
throw new Error(`Unable to download OpenTofu from ${url}`);
|
||||
if (!pathToCLI) {
|
||||
throw new Error('Unable to unzip OpenTofu');
|
||||
}
|
||||
|
||||
return pathToCLI;
|
||||
|
|
@ -143,7 +147,7 @@ async function run () {
|
|||
}
|
||||
|
||||
// Download requested version
|
||||
const pathToCLI = await downloadCLI(build.url);
|
||||
const pathToCLI = await downloadAndExtractCLI(build.url);
|
||||
|
||||
// Install our wrapper
|
||||
if (wrapper) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue