Skip to content

Commit 2d53d29

Browse files
committed
Use actions/exec for getting version
1 parent 1e163de commit 2d53d29

3 files changed

Lines changed: 13 additions & 24 deletions

File tree

dist/index.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15199,16 +15199,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
1519915199
result["default"] = mod;
1520015200
return result;
1520115201
};
15202-
var __importDefault = (this && this.__importDefault) || function (mod) {
15203-
return (mod && mod.__esModule) ? mod : { "default": mod };
15204-
};
1520515202
Object.defineProperty(exports, "__esModule", { value: true });
1520615203
const core = __importStar(__webpack_require__(470));
15207-
const io = __importStar(__webpack_require__(1));
15204+
const exec = __importStar(__webpack_require__(986));
1520815205
const installer = __importStar(__webpack_require__(749));
1520915206
const auth = __importStar(__webpack_require__(202));
1521015207
const path = __importStar(__webpack_require__(622));
15211-
const child_process_1 = __importDefault(__webpack_require__(129));
1521215208
function run() {
1521315209
return __awaiter(this, void 0, void 0, function* () {
1521415210
try {
@@ -15224,15 +15220,11 @@ function run() {
1522415220
yield installer.getNode(version);
1522515221
}
1522615222
// Output version of node and npm that are being used
15227-
const nodePath = yield io.which('node');
15228-
const nodeVersion = child_process_1.default.execSync(`"${nodePath}" --version`);
15229-
console.log(`Node Version: ${nodeVersion}`);
15230-
const npmPath = yield io.which('npm');
15231-
// Older versions of Node don't include npm
15232-
if (npmPath) {
15233-
const npmVersion = child_process_1.default.execSync(`"${npmPath}" --version`);
15234-
console.log(`npm Version: ${npmVersion}`);
15235-
}
15223+
const nodeVersion = exec.exec(`"$ --version`);
15224+
// Older versions of Node don't include npm, so don't let this call fail
15225+
const npmVersion = exec.exec(`npm --version`, undefined, {
15226+
ignoreReturnCode: true
15227+
});
1523615228
const registryUrl = core.getInput('registry-url');
1523715229
const alwaysAuth = core.getInput('always-auth');
1523815230
if (registryUrl) {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"license": "MIT",
2525
"dependencies": {
2626
"@actions/core": "^1.2.2",
27+
"@actions/exec": "^1.0.3",
2728
"@actions/github": "^1.1.0",
2829
"@actions/http-client": "^1.0.6",
2930
"@actions/io": "^1.0.2",

src/setup-node.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as core from '@actions/core';
2+
import * as exec from '@actions/exec';
23
import * as io from '@actions/io';
34
import * as installer from './installer';
45
import * as auth from './authutil';
56
import * as path from 'path';
6-
import cp from 'child_process';
77

88
async function run() {
99
try {
@@ -20,16 +20,12 @@ async function run() {
2020
}
2121

2222
// Output version of node and npm that are being used
23-
const nodePath = await io.which('node');
24-
const nodeVersion = cp.execSync(`"${nodePath}" --version`);
25-
console.log(`Node Version: ${nodeVersion}`);
23+
const nodeVersion = exec.exec(`"$ --version`);
2624

27-
const npmPath = await io.which('npm');
28-
// Older versions of Node don't include npm
29-
if (npmPath) {
30-
const npmVersion = cp.execSync(`"${npmPath}" --version`);
31-
console.log(`npm Version: ${npmVersion}`);
32-
}
25+
// Older versions of Node don't include npm, so don't let this call fail
26+
const npmVersion = exec.exec(`npm --version`, undefined, {
27+
ignoreReturnCode: true
28+
});
3329

3430
const registryUrl: string = core.getInput('registry-url');
3531
const alwaysAuth: string = core.getInput('always-auth');

0 commit comments

Comments
 (0)