diff --git a/dist/index.js b/dist/index.js index 4e803010..28a33e76 100644 --- a/dist/index.js +++ b/dist/index.js @@ -15199,16 +15199,12 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(__webpack_require__(470)); -const io = __importStar(__webpack_require__(1)); +const exec = __importStar(__webpack_require__(986)); const installer = __importStar(__webpack_require__(749)); const auth = __importStar(__webpack_require__(202)); const path = __importStar(__webpack_require__(622)); -const child_process_1 = __importDefault(__webpack_require__(129)); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -15224,15 +15220,11 @@ function run() { yield installer.getNode(version); } // Output version of node and npm that are being used - const nodePath = yield io.which('node'); - const nodeVersion = child_process_1.default.execSync(`"${nodePath}" --version`); - console.log(`Node Version: ${nodeVersion}`); - const npmPath = yield io.which('npm'); - // 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 nodeVersion = exec.exec(`"$ --version`); + // Older versions of Node don't include npm, so don't let this call fail + const npmVersion = exec.exec(`npm --version`, undefined, { + ignoreReturnCode: true + }); const registryUrl = core.getInput('registry-url'); const alwaysAuth = core.getInput('always-auth'); if (registryUrl) { diff --git a/package.json b/package.json index 0321d497..9607e46d 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "license": "MIT", "dependencies": { "@actions/core": "^1.2.2", + "@actions/exec": "^1.0.3", "@actions/github": "^1.1.0", "@actions/http-client": "^1.0.6", "@actions/io": "^1.0.2", diff --git a/src/setup-node.ts b/src/setup-node.ts index 4573cf26..5fa89d77 100644 --- a/src/setup-node.ts +++ b/src/setup-node.ts @@ -1,9 +1,9 @@ import * as core from '@actions/core'; +import * as exec from '@actions/exec'; import * as io from '@actions/io'; import * as installer from './installer'; import * as auth from './authutil'; import * as path from 'path'; -import cp from 'child_process'; async function run() { try { @@ -20,16 +20,12 @@ async function run() { } // Output version of node and npm that are being used - const nodePath = await io.which('node'); - const nodeVersion = cp.execSync(`"${nodePath}" --version`); - console.log(`Node Version: ${nodeVersion}`); + const nodeVersion = exec.exec(`"$ --version`); - const npmPath = await io.which('npm'); - // Older versions of Node don't include npm - if (npmPath) { - const npmVersion = cp.execSync(`"${npmPath}" --version`); - console.log(`npm Version: ${npmVersion}`); - } + // Older versions of Node don't include npm, so don't let this call fail + const npmVersion = exec.exec(`npm --version`, undefined, { + ignoreReturnCode: true + }); const registryUrl: string = core.getInput('registry-url'); const alwaysAuth: string = core.getInput('always-auth');