From 963824662d8b95d8483d706eb9f781cf11da2533 Mon Sep 17 00:00:00 2001 From: Gerard Ribugent Date: Thu, 22 Jan 2026 14:29:50 +0100 Subject: [PATCH] Update shebang from wrapper to use the node version that action is running --- lib/setup-terraform.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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;