mirror of
https://github.com/actions/setup-node.git
synced 2024-12-23 09:29:49 +08:00
refactor: remove locally caught exceptions
This commit is contained in:
parent
94f88d78c4
commit
3a1b76e782
17
dist/setup/index.js
vendored
17
dist/setup/index.js
vendored
|
@ -71780,18 +71780,13 @@ function parseNodeVersionFile(contents) {
|
||||||
core.warning('Node version file is not JSON file');
|
core.warning('Node version file is not JSON file');
|
||||||
}
|
}
|
||||||
if (!nodeVersion) {
|
if (!nodeVersion) {
|
||||||
try {
|
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
|
||||||
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
|
nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version;
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// In the case of an unknown format,
|
||||||
|
// return as is and evaluate the version separately.
|
||||||
|
if (!nodeVersion)
|
||||||
|
nodeVersion = contents.trim();
|
||||||
return nodeVersion;
|
return nodeVersion;
|
||||||
}
|
}
|
||||||
exports.parseNodeVersionFile = parseNodeVersionFile;
|
exports.parseNodeVersionFile = parseNodeVersionFile;
|
||||||
|
|
|
@ -506,18 +506,14 @@ export function parseNodeVersionFile(contents: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nodeVersion) {
|
if (!nodeVersion) {
|
||||||
try {
|
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
|
||||||
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
|
nodeVersion = found?.groups?.version;
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In the case of an unknown format,
|
||||||
|
// return as is and evaluate the version separately.
|
||||||
|
if (!nodeVersion) nodeVersion = contents.trim();
|
||||||
|
|
||||||
return nodeVersion as string;
|
return nodeVersion as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user