From ffde5387817e21e1d9cde5fef7e8269953c9768b Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Tue, 21 Apr 2020 11:21:23 -0400 Subject: [PATCH] Only include npm version if npm exists --- dist/index.js | 7 +++++-- src/setup-node.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0aeaf5e..394eb35 100644 --- a/dist/index.js +++ b/dist/index.js @@ -15228,8 +15228,11 @@ function run() { const nodeVersion = child_process_1.default.execSync(`${nodePath} --version`); console.log(`Node Version: ${nodeVersion}`); const npmPath = yield io.which('npm'); - const npmVersion = child_process_1.default.execSync(`${npmPath} --version`); - console.log(`npm Version: ${npmVersion}`); + // Older versions of Node don't include npm + if (npmPath) { + const npmVersion = child_process_1.default.execSync(`${npmPath} --version`); + console.log(`npm Version: ${npmVersion}`); + } const registryUrl = core.getInput('registry-url'); const alwaysAuth = core.getInput('always-auth'); if (registryUrl) { diff --git a/src/setup-node.ts b/src/setup-node.ts index 28c106e..b954493 100644 --- a/src/setup-node.ts +++ b/src/setup-node.ts @@ -25,8 +25,11 @@ async function run() { console.log(`Node Version: ${nodeVersion}`); const npmPath = await io.which('npm'); - const npmVersion = cp.execSync(`${npmPath} --version`); - console.log(`npm Version: ${npmVersion}`); + // Older versions of Node don't include npm + if (npmPath) { + const npmVersion = cp.execSync(`${npmPath} --version`); + console.log(`npm Version: ${npmVersion}`); + } const registryUrl: string = core.getInput('registry-url'); const alwaysAuth: string = core.getInput('always-auth');