From 67539e193ee24beb33ac1ca1d24bd95dfa7bab53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Hern=C3=A1ndez?= Date: Mon, 23 Nov 2020 19:34:52 +0100 Subject: [PATCH] Throwing if node-arch is provided on linux and macos (dcodeIO#8) --- README.md | 1 + index.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d1c59bc..6499d31 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ The node.js mirror to use, e.g. `https://nodejs.org/download/v8-canary/` for nod ### node-arch (Windows only) The architecture of node.js to use. Defaults to system arch if omitted. More info about nvm-windows arch modifier [here](https://github.com/coreybutler/nvm-windows#usage). +Note that the action will reject to run on both GNU/Linux and macOS if node-arch is provided. ## Example usage: diff --git a/index.js b/index.js index e1ef50f..bee5ec5 100644 --- a/index.js +++ b/index.js @@ -25,15 +25,16 @@ async function resolveVersion(version, mirror) { (async () => { let mirror = core.getInput("node-mirror") || "https://nodejs.org/dist/"; let version = await resolveVersion(core.getInput("node-version"), mirror); + let arch = core.getInput("node-arch") || ""; if (process.platform == "win32") { - let arch = core.getInput("node-arch") || ""; runScript("powershell", ".\\install.ps1", version, mirror, arch); } else { + if (arch) throw Error("Invalid input parameter: node-arch"); runScript("bash", "install.sh", version, mirror); } })(); -// arch only applies to Windows platform, so it's a no-op on GNU/Linux and macOS +// arch only applies to Windows platform, so it will throw on both GNU/Linux and macOS when provided function runScript(shell, script, version, mirror, arch) { const child = child_process.spawn(shell, [ script, version, mirror, arch ], { cwd: __dirname }); const stdout = [];