Skip to content
Merged
13 changes: 12 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,19 @@ async function downloadCLI (url) {
core.debug(`Downloading Terraform CLI from ${url}`);
const pathToCLIZip = await tc.downloadTool(url);

let pathToCLI = '';

core.debug('Extracting Terraform CLI zip file');
const pathToCLI = await tc.extractZip(pathToCLIZip);
if (os.platform().startsWith('win')) {
core.debug(`Terraform CLI Download Path is ${pathToCLIZip}`);
const 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(`Terraform CLI path is ${pathToCLI}.`);

if (!pathToCLIZip || !pathToCLI) {
Expand Down
13 changes: 12 additions & 1 deletion lib/setup-terraform.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,19 @@ async function downloadCLI (url) {
core.debug(`Downloading Terraform CLI from ${url}`);
const pathToCLIZip = await tc.downloadTool(url);

let pathToCLI = '';

core.debug('Extracting Terraform CLI zip file');
const pathToCLI = await tc.extractZip(pathToCLIZip);
if (os.platform().startsWith('win')) {
core.debug(`Terraform CLI Download Path is ${pathToCLIZip}`);
const 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(`Terraform CLI path is ${pathToCLI}.`);

if (!pathToCLIZip || !pathToCLI) {
Expand Down
2 changes: 2 additions & 0 deletions test/setup-terraform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ describe('Setup Terraform', () => {
.fn()
.mockReturnValueOnce('file.zip');

io.mv = jest.fn();

tc.extractZip = jest
.fn()
.mockReturnValueOnce('file');
Expand Down