diff --git a/lib/setup-terraform.js b/lib/setup-terraform.js index 87e7575..f3269a6 100644 --- a/lib/setup-terraform.js +++ b/lib/setup-terraform.js @@ -81,8 +81,13 @@ async function installWrapper (pathToCLI) { try { source = path.resolve([__dirname, '..', 'wrapper', 'dist', 'index.js'].join(path.sep)); target = [pathToCLI, 'terraform'].join(path.sep); - core.debug(`Copying ${source} to ${target}.`); - await io.cp(source, target); + + core.debug(`Reading wrapper from ${source} and updating shebang.`); + const wrapperContent = (await fs.readFile(source, 'utf8')).split('\n'); + wrapperContent[0] = `#!${process.argv[0]}`; + + core.debug(`Writing updated wrapper to ${target}.`); + await fs.writeFile(target, wrapperContent.join('\n')); } catch (e) { core.error(`Unable to copy ${source} to ${target}.`); throw e;