File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9292 fail-fast : false
9393 matrix :
9494 os : [ubuntu-latest, windows-latest, macos-latest]
95- node-version-file : [.nvmrc, .tool-versions]
95+ node-version-file : [.nvmrc, .tool-versions, package.json ]
9696 steps :
9797 - uses : actions/checkout@v3
9898 - name : Setup node from node version file
Original file line number Diff line number Diff line change 11{
22 "engines" : {
3- "node" : " >= 14.0.0"
3+ "node" : " ^ 14.0.0"
44 }
55}
Original file line number Diff line number Diff line change @@ -71770,13 +71770,18 @@ function translateArchToDistUrl(arch) {
7177071770function parseNodeVersionFile(contents) {
7177171771 var _a, _b;
7177271772 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+ }
7177571781 if (!nodeVersion) {
7177671782 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;
7178071785 if (!nodeVersion)
7178171786 throw new Error();
7178271787 }
Original file line number Diff line number Diff line change @@ -497,14 +497,18 @@ function translateArchToDistUrl(arch: string): string {
497497export function parseNodeVersionFile ( contents : string ) : string {
498498 let nodeVersion : string | undefined ;
499499
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+ }
502507
503508 if ( ! nodeVersion ) {
504509 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 ;
508512
509513 if ( ! nodeVersion ) throw new Error ( ) ;
510514 } catch ( err ) {
You can’t perform that action at this time.
0 commit comments