mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 09:21:00 +00:00
Non-json file error handling
This commit is contained in:
parent
0db4699b29
commit
e22d92112e
2 changed files with 11 additions and 2 deletions
7
dist/setup/index.js
vendored
7
dist/setup/index.js
vendored
|
@ -71772,7 +71772,12 @@ function parseNodeVersionFile(contents) {
|
||||||
let nodeVersion;
|
let nodeVersion;
|
||||||
// Try parsing the file as an NPM `package.json`
|
// Try parsing the file as an NPM `package.json`
|
||||||
// file.
|
// 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) {
|
if (!nodeVersion) {
|
||||||
try {
|
try {
|
||||||
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
|
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`
|
// Try parsing the file as an NPM `package.json`
|
||||||
// file.
|
// 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) {
|
if (!nodeVersion) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Reference in a new issue