mirror of
https://github.com/actions/setup-node
synced 2025-05-14 11:57:45 +00:00
Non-json file error handling
This commit is contained in:
parent
0db4699b29
commit
e22d92112e
7
dist/setup/index.js
vendored
7
dist/setup/index.js
vendored
@ -71772,7 +71772,12 @@ function parseNodeVersionFile(contents) {
|
||||
let nodeVersion;
|
||||
// Try parsing the file as an NPM `package.json`
|
||||
// file.
|
||||
nodeVersion = (_a = JSON.parse(contents).engines) === null || _a === void 0 ? void 0 : _a.node;
|
||||
try {
|
||||
nodeVersion = (_a = JSON.parse(contents).engines) === null || _a === void 0 ? void 0 : _a.node;
|
||||
}
|
||||
catch (_c) {
|
||||
core.warning("Node version file is not JSON file");
|
||||
}
|
||||
if (!nodeVersion) {
|
||||
try {
|
||||
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
|
||||
|
@ -499,7 +499,11 @@ export function parseNodeVersionFile(contents: string): string {
|
||||
|
||||
// Try parsing the file as an NPM `package.json`
|
||||
// file.
|
||||
nodeVersion = JSON.parse(contents).engines?.node;
|
||||
try {
|
||||
nodeVersion = JSON.parse(contents).engines?.node;
|
||||
} catch {
|
||||
core.warning("Node version file is not JSON file")
|
||||
}
|
||||
|
||||
if (!nodeVersion) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user