Skip to content

Commit

Permalink
refactor: remove locally caught exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jef committed Aug 4, 2022
1 parent 94f88d7 commit 3a1b76e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
17 changes: 6 additions & 11 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?(?<version>[^\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?(?<version>[^\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;
Expand Down
16 changes: 6 additions & 10 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,14 @@ export function parseNodeVersionFile(contents: string): string {
}

if (!nodeVersion) {
try {
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\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?(?<version>[^\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;
}

Expand Down

0 comments on commit 3a1b76e

Please sign in to comment.