File tree 4 files changed +23
-13
lines changed 4 files changed +23
-13
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
"volta" : {
6
6
"node" : " 14.0.0"
Original file line number Diff line number Diff line change @@ -71770,14 +71770,19 @@ function translateArchToDistUrl(arch) {
71770
71770
function parseNodeVersionFile(contents) {
71771
71771
var _a, _b, _c;
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` file.
71774
+ try {
71775
+ nodeVersion = (_a = JSON.parse(contents).volta) === null || _a === void 0 ? void 0 : _a.node;
71776
+ if (!nodeVersion)
71777
+ nodeVersion = (_b = JSON.parse(contents).engines) === null || _b === void 0 ? void 0 : _b.node;
71778
+ }
71779
+ catch (_d) {
71780
+ core.warning('Node version file is not JSON file');
71781
+ }
71775
71782
if (!nodeVersion) {
71776
71783
try {
71777
- // Try parsing the file as an NPM `package.json` file.
71778
- nodeVersion = (_b = JSON.parse(contents).volta) === null || _b === void 0 ? void 0 : _b.node;
71779
- if (!nodeVersion)
71780
- nodeVersion = (_c = JSON.parse(contents).engines) === null || _c === void 0 ? void 0 : _c.node;
71784
+ const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
71785
+ nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version;
71781
71786
if (!nodeVersion)
71782
71787
throw new Error();
71783
71788
}
Original file line number Diff line number Diff line change @@ -497,14 +497,19 @@ 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` file.
501
+ try {
502
+ nodeVersion = JSON . parse ( contents ) . volta ?. node ;
503
+ if ( ! nodeVersion ) 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` file.
506
- nodeVersion = JSON . parse ( contents ) . volta ?. node ;
507
- if ( ! nodeVersion ) 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 ;
512
+
508
513
if ( ! nodeVersion ) throw new Error ( ) ;
509
514
} catch ( err ) {
510
515
// In the case of an unknown format,
You can’t perform that action at this time.
0 commit comments