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..ab6eac8 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", [ path.join(__dirname, "install.sh"), version, mirror ], { cwd: cwd }); const stdout = []; child.stdout.on("data", out => { stdout.push(out);