Non-json file error handling

This commit is contained in:
Vladimir Safonkin 2022-08-03 11:30:15 +02:00
parent 0db4699b29
commit e22d92112e
2 changed files with 11 additions and 2 deletions

5
dist/setup/index.js vendored
View file

@ -71772,7 +71772,12 @@ function parseNodeVersionFile(contents) {
let nodeVersion;
// Try parsing the file as an NPM `package.json`
// file.
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);

View file

@ -499,7 +499,11 @@ export function parseNodeVersionFile(contents: string): string {
// Try parsing the file as an NPM `package.json`
// file.
try {
nodeVersion = JSON.parse(contents).engines?.node;
} catch {
core.warning("Node version file is not JSON file")
}
if (!nodeVersion) {
try {