Skip to content

Commit 3a1b76e

Browse files
committed
refactor: remove locally caught exceptions
1 parent 94f88d7 commit 3a1b76e

File tree

2 files changed

+12
-21
lines changed

2 files changed

+12
-21
lines changed

dist/setup/index.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71780,18 +71780,13 @@ function parseNodeVersionFile(contents) {
7178071780
core.warning('Node version file is not JSON file');
7178171781
}
7178271782
if (!nodeVersion) {
71783-
try {
71784-
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
71785-
nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version;
71786-
if (!nodeVersion)
71787-
throw new Error();
71788-
}
71789-
catch (err) {
71790-
// In the case of an unknown format,
71791-
// return as is and evaluate the version separately.
71792-
nodeVersion = contents.trim();
71793-
}
71783+
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
71784+
nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version;
7179471785
}
71786+
// In the case of an unknown format,
71787+
// return as is and evaluate the version separately.
71788+
if (!nodeVersion)
71789+
nodeVersion = contents.trim();
7179571790
return nodeVersion;
7179671791
}
7179771792
exports.parseNodeVersionFile = parseNodeVersionFile;

src/installer.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -506,18 +506,14 @@ export function parseNodeVersionFile(contents: string): string {
506506
}
507507

508508
if (!nodeVersion) {
509-
try {
510-
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
511-
nodeVersion = found?.groups?.version;
512-
513-
if (!nodeVersion) throw new Error();
514-
} catch (err) {
515-
// In the case of an unknown format,
516-
// return as is and evaluate the version separately.
517-
nodeVersion = contents.trim();
518-
}
509+
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
510+
nodeVersion = found?.groups?.version;
519511
}
520512

513+
// In the case of an unknown format,
514+
// return as is and evaluate the version separately.
515+
if (!nodeVersion) nodeVersion = contents.trim();
516+
521517
return nodeVersion as string;
522518
}
523519

0 commit comments

Comments
 (0)