File tree 4 files changed +21
-12
lines changed
4 files changed +21
-12
lines changed Original file line number Diff line number Diff line change 92
92
fail-fast : false
93
93
matrix :
94
94
os : [ubuntu-latest, windows-latest, macos-latest]
95
- node-version-file : [.nvmrc, .tool-versions]
95
+ node-version-file : [.nvmrc, .tool-versions, package.json ]
96
96
steps :
97
97
- uses : actions/checkout@v3
98
98
- name : Setup node from node version file
Original file line number Diff line number Diff line change 1
1
{
2
2
"engines" : {
3
- "node" : " >= 14.0.0"
3
+ "node" : " ^ 14.0.0"
4
4
}
5
5
}
Original file line number Diff line number Diff line change @@ -71770,13 +71770,18 @@ function translateArchToDistUrl(arch) {
71770
71770
function parseNodeVersionFile(contents) {
71771
71771
var _a, _b;
71772
71772
let nodeVersion;
71773
- const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
71774
- nodeVersion = (_a = found === null || found === void 0 ? void 0 : found.groups) === null || _a === void 0 ? void 0 : _a.version;
71773
+ // Try parsing the file as an NPM `package.json`
71774
+ // file.
71775
+ try {
71776
+ nodeVersion = (_a = JSON.parse(contents).engines) === null || _a === void 0 ? void 0 : _a.node;
71777
+ }
71778
+ catch (_c) {
71779
+ core.warning('Node version file is not JSON file');
71780
+ }
71775
71781
if (!nodeVersion) {
71776
71782
try {
71777
- // Try parsing the file as an NPM `package.json`
71778
- // file.
71779
- nodeVersion = (_b = JSON.parse(contents).engines) === null || _b === void 0 ? void 0 : _b.node;
71783
+ const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
71784
+ nodeVersion = (_b = found === null || found === void 0 ? void 0 : found.groups) === null || _b === void 0 ? void 0 : _b.version;
71780
71785
if (!nodeVersion)
71781
71786
throw new Error();
71782
71787
}
Original file line number Diff line number Diff line change @@ -497,14 +497,18 @@ function translateArchToDistUrl(arch: string): string {
497
497
export function parseNodeVersionFile ( contents : string ) : string {
498
498
let nodeVersion : string | undefined ;
499
499
500
- const found = contents . match ( / ^ (?: n o d e j s \s + ) ? v ? (?< version > [ ^ \s ] + ) $ / m) ;
501
- nodeVersion = found ?. groups ?. version ;
500
+ // Try parsing the file as an NPM `package.json`
501
+ // file.
502
+ try {
503
+ nodeVersion = JSON . parse ( contents ) . engines ?. node ;
504
+ } catch {
505
+ core . warning ( 'Node version file is not JSON file' ) ;
506
+ }
502
507
503
508
if ( ! nodeVersion ) {
504
509
try {
505
- // Try parsing the file as an NPM `package.json`
506
- // file.
507
- nodeVersion = JSON . parse ( contents ) . engines ?. node ;
510
+ const found = contents . match ( / ^ (?: n o d e j s \s + ) ? v ? (?< version > [ ^ \s ] + ) $ / m) ;
511
+ nodeVersion = found ?. groups ?. version ;
508
512
509
513
if ( ! nodeVersion ) throw new Error ( ) ;
510
514
} catch ( err ) {
You can’t perform that action at this time.
0 commit comments