From d17d2e6f1bb5446784fbca71a48a199c986e95bf Mon Sep 17 00:00:00 2001 From: David Fox-Powell Date: Thu, 26 Sep 2019 10:03:35 -0400 Subject: [PATCH 1/2] modify cwd --- action.yml | 3 +++ index.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 47f0ce3..123e9f2 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,9 @@ inputs: node-mirror: description: The node.js mirror to use default: https://nodejs.org/dist/ + package-manager: + description: The package manager to use. Uses npm@latest if omitted. + default: npm runs: using: node12 main: index.js diff --git a/index.js b/index.js index 00ff83a..f996bb4 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,11 @@ const child_process = require("child_process"); +const fs = require("fs"); const path = require("path"); const core = require("@actions/core"); const version = core.getInput("node-version"); const mirror = core.getInput("node-mirror"); -const child = child_process.spawn("bash", [ "install.sh", version, mirror ], { cwd: __dirname }); +const cwd = fs.existsSync(path.join(process.cwd(), `.nvmrc`)) ? process.cwd() : __dirname; +const child = child_process.spawn("bash", [ "install.sh", version, mirror ], { cwd: cwd }); const stdout = []; child.stdout.on("data", out => { stdout.push(out); From c014ea6ec1ac59495234bc9885912d7172e77555 Mon Sep 17 00:00:00 2001 From: David Fox-Powell Date: Thu, 26 Sep 2019 10:17:37 -0400 Subject: [PATCH 2/2] reference full path to install script --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index f996bb4..ab6eac8 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ const core = require("@actions/core"); const version = core.getInput("node-version"); const mirror = core.getInput("node-mirror"); const cwd = fs.existsSync(path.join(process.cwd(), `.nvmrc`)) ? process.cwd() : __dirname; -const child = child_process.spawn("bash", [ "install.sh", version, mirror ], { cwd: cwd }); +const child = child_process.spawn("bash", [ path.join(__dirname, "install.sh"), version, mirror ], { cwd: cwd }); const stdout = []; child.stdout.on("data", out => { stdout.push(out);