mirror of
https://github.com/actions/setup-node.git
synced 2024-11-10 05:31:07 +07:00
add try catch
This commit is contained in:
parent
48de4c13f6
commit
28ad38fe06
18
dist/setup/index.js
vendored
18
dist/setup/index.js
vendored
@ -71846,17 +71846,13 @@ function run() {
|
|||||||
yield installer.getNode(version, stable, checkLatest, auth, arch);
|
yield installer.getNode(version, stable, checkLatest, auth, arch);
|
||||||
}
|
}
|
||||||
// Output version of node is being used
|
// Output version of node is being used
|
||||||
let installedVersion = '';
|
try {
|
||||||
const result = yield exec.exec('node', ['--version'], {
|
const { stdout: installedVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true, silent: false });
|
||||||
ignoreReturnCode: true,
|
core.setOutput('node-version', installedVersion);
|
||||||
silent: false,
|
}
|
||||||
listeners: {
|
catch (err) {
|
||||||
stdout: data => {
|
core.setOutput('node-version', '');
|
||||||
installedVersion = data.toString();
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
core.setOutput('node-version', installedVersion);
|
|
||||||
const registryUrl = core.getInput('registry-url');
|
const registryUrl = core.getInput('registry-url');
|
||||||
const alwaysAuth = core.getInput('always-auth');
|
const alwaysAuth = core.getInput('always-auth');
|
||||||
if (registryUrl) {
|
if (registryUrl) {
|
||||||
|
21
src/main.ts
21
src/main.ts
@ -41,17 +41,16 @@ export async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Output version of node is being used
|
// Output version of node is being used
|
||||||
let installedVersion = '';
|
try {
|
||||||
const result = await exec.exec('node', ['--version'], {
|
const {stdout: installedVersion} = await exec.getExecOutput(
|
||||||
ignoreReturnCode: true,
|
'node',
|
||||||
silent: false,
|
['--version'],
|
||||||
listeners: {
|
{ignoreReturnCode: true, silent: false}
|
||||||
stdout: data => {
|
);
|
||||||
installedVersion = data.toString();
|
core.setOutput('node-version', installedVersion);
|
||||||
}
|
} catch (err) {
|
||||||
}
|
core.setOutput('node-version', '');
|
||||||
});
|
}
|
||||||
core.setOutput('node-version', installedVersion);
|
|
||||||
|
|
||||||
const registryUrl: string = core.getInput('registry-url');
|
const registryUrl: string = core.getInput('registry-url');
|
||||||
const alwaysAuth: string = core.getInput('always-auth');
|
const alwaysAuth: string = core.getInput('always-auth');
|
||||||
|
Loading…
Reference in New Issue
Block a user