Skip to content

Commit

Permalink
add try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-shibanov committed Jul 12, 2022
1 parent 48de4c1 commit 28ad38f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
18 changes: 7 additions & 11 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71846,17 +71846,13 @@ function run() {
yield installer.getNode(version, stable, checkLatest, auth, arch);
}
// Output version of node is being used
let installedVersion = '';
const result = yield exec.exec('node', ['--version'], {
ignoreReturnCode: true,
silent: false,
listeners: {
stdout: data => {
installedVersion = data.toString();
}
}
});
core.setOutput('node-version', installedVersion);
try {
const { stdout: installedVersion } = yield exec.getExecOutput('node', ['--version'], { ignoreReturnCode: true, silent: false });
core.setOutput('node-version', installedVersion);
}
catch (err) {
core.setOutput('node-version', '');
}
const registryUrl = core.getInput('registry-url');
const alwaysAuth = core.getInput('always-auth');
if (registryUrl) {
Expand Down
21 changes: 10 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,16 @@ export async function run() {
}

// Output version of node is being used
let installedVersion = '';
const result = await exec.exec('node', ['--version'], {
ignoreReturnCode: true,
silent: false,
listeners: {
stdout: data => {
installedVersion = data.toString();
}
}
});
core.setOutput('node-version', installedVersion);
try {
const {stdout: installedVersion} = await exec.getExecOutput(
'node',
['--version'],
{ignoreReturnCode: true, silent: false}
);
core.setOutput('node-version', installedVersion);
} catch (err) {
core.setOutput('node-version', '');
}

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

0 comments on commit 28ad38f

Please sign in to comment.