From 07c30f59da93270ba280c6f309fae69d53271ab2 Mon Sep 17 00:00:00 2001 From: Jonathan Camara Date: Wed, 27 Apr 2022 16:32:54 -0500 Subject: [PATCH] fix: only change file extension of we are on Windows --- dist/index.js | 16 +++++++++++----- lib/setup-terraform.js | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index ab6708a..f0fa4de 100644 --- a/dist/index.js +++ b/dist/index.js @@ -38,13 +38,19 @@ async function downloadCLI (url) { core.debug(`Downloading Terraform CLI from ${url}`); const pathToCLIZip = await tc.downloadTool(url); - core.debug(`Terraform CLI Download Path is ${pathToCLIZip}`) - fixedPathToCLIZip=`${pathToCLIZip}.zip` - io.mv(pathToCLIZip,fixedPathToCLIZip) - core.debug(`Moved download to ${fixedPathToCLIZip}`) + const pathToCLI = ""; + + if (os.platform().startsWith('win')) { + core.debug(`Terraform CLI Download Path is ${pathToCLIZip}`) + fixedPathToCLIZip = `${pathToCLIZip}.zip` + io.mv(pathToCLIZip, fixedPathToCLIZip) + core.debug(`Moved download to ${fixedPathToCLIZip}`) + pathToCLI = await tc.extractZip(fixedPathToCLIZip); + } else { + pathToCLI = await tc.extractZip(pathToCLIZip); + } core.debug('Extracting Terraform CLI zip file'); - const pathToCLI = await tc.extractZip(fixedPathToCLIZip); core.debug(`Terraform CLI path is ${pathToCLI}.`); if (!pathToCLIZip || !pathToCLI) { diff --git a/lib/setup-terraform.js b/lib/setup-terraform.js index c4a080f..e743f3f 100644 --- a/lib/setup-terraform.js +++ b/lib/setup-terraform.js @@ -32,13 +32,19 @@ async function downloadCLI (url) { core.debug(`Downloading Terraform CLI from ${url}`); const pathToCLIZip = await tc.downloadTool(url); - core.debug(`Terraform CLI Download Path is ${pathToCLIZip}`) - fixedPathToCLIZip=`${pathToCLIZip}.zip` - io.mv(pathToCLIZip,fixedPathToCLIZip) - core.debug(`Moved download to ${fixedPathToCLIZip}`) + const pathToCLI = ""; + + if (os.platform().startsWith('win')) { + core.debug(`Terraform CLI Download Path is ${pathToCLIZip}`) + fixedPathToCLIZip = `${pathToCLIZip}.zip` + io.mv(pathToCLIZip, fixedPathToCLIZip) + core.debug(`Moved download to ${fixedPathToCLIZip}`) + pathToCLI = await tc.extractZip(fixedPathToCLIZip); + } else { + pathToCLI = await tc.extractZip(pathToCLIZip); + } core.debug('Extracting Terraform CLI zip file'); - const pathToCLI = await tc.extractZip(fixedPathToCLIZip); core.debug(`Terraform CLI path is ${pathToCLI}.`); if (!pathToCLIZip || !pathToCLI) {