diff --git a/dist/setup/index.js b/dist/setup/index.js index efd8162..684be49 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -71780,18 +71780,13 @@ function parseNodeVersionFile(contents) { core.warning('Node version file is not JSON file'); } if (!nodeVersion) { - try { - const found = contents.match(/^(?:nodejs\s+)?v?(?[^\s]+)$/m); - nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version; - if (!nodeVersion) - throw new Error(); - } - catch (err) { - // In the case of an unknown format, - // return as is and evaluate the version separately. - nodeVersion = contents.trim(); - } + const found = contents.match(/^(?:nodejs\s+)?v?(?[^\s]+)$/m); + nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version; } + // In the case of an unknown format, + // return as is and evaluate the version separately. + if (!nodeVersion) + nodeVersion = contents.trim(); return nodeVersion; } exports.parseNodeVersionFile = parseNodeVersionFile; diff --git a/src/installer.ts b/src/installer.ts index 1e5e562..bd9c842 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -506,18 +506,14 @@ export function parseNodeVersionFile(contents: string): string { } if (!nodeVersion) { - try { - const found = contents.match(/^(?:nodejs\s+)?v?(?[^\s]+)$/m); - nodeVersion = found?.groups?.version; - - if (!nodeVersion) throw new Error(); - } catch (err) { - // In the case of an unknown format, - // return as is and evaluate the version separately. - nodeVersion = contents.trim(); - } + const found = contents.match(/^(?:nodejs\s+)?v?(?[^\s]+)$/m); + nodeVersion = found?.groups?.version; } + // In the case of an unknown format, + // return as is and evaluate the version separately. + if (!nodeVersion) nodeVersion = contents.trim(); + return nodeVersion as string; }