Skip to content

Commit

Permalink
Throwing if node-arch is provided on linux and macos (dcodeIO#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
javihernandez committed Nov 23, 2020
1 parent 4aa073e commit 67539e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down

0 comments on commit 67539e1

Please sign in to comment.