Use actions/exec for getting version

This commit is contained in:
Josh Gross 2020-04-21 14:03:26 -04:00
parent 1e163ded31
commit 2d53d29868
No known key found for this signature in database
GPG key ID: 17A6308EA2144978
3 changed files with 13 additions and 24 deletions

20
dist/index.js vendored
View file

@ -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) {

View file

@ -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",

View file

@ -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');