feat: add node-lts-codename output

This commit is contained in:
Filip Skokan 2022-10-26 11:06:01 +02:00
parent 16352bb09b
commit c81dbb113a
3 changed files with 51 additions and 0 deletions

View file

@ -115,6 +115,12 @@ export async function printEnvDetailsAndSetOutput() {
core.info(`${tool}: ${output}`);
});
promises.push(
getLtsCodename().then(codename => {
core.setOutput('node-lts-codename', codename);
})
);
await Promise.all(promises);
core.endGroup();
@ -137,3 +143,25 @@ async function getToolVersion(tool: string, options: string[]) {
return '';
}
}
async function getLtsCodename() {
try {
const {stdout, stderr, exitCode} = await exec.getExecOutput(
'node',
["-p 'process.release.lts || process.exit(0)'"],
{
ignoreReturnCode: true,
silent: true
}
);
if (exitCode > 0) {
core.warning(`[warning]${stderr}`);
return '';
}
return stdout;
} catch (err) {
return '';
}
}