@@ -93728,7 +93728,13 @@ function resolveVersionInput() {
9372893728 if (!fs_1.default.existsSync(versionFilePath)) {
9372993729 throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
9373093730 }
93731- version = (0, util_1.parseNodeVersionFile)(fs_1.default.readFileSync(versionFilePath, 'utf8'));
93731+ const parsedVersion = (0, util_1.parseNodeVersionFile)(fs_1.default.readFileSync(versionFilePath, 'utf8'));
93732+ if (parsedVersion) {
93733+ version = parsedVersion;
93734+ }
93735+ else {
93736+ core.warning(`Could not determine node version from ${versionFilePath}. Falling back`);
93737+ }
9373293738 core.info(`Resolved ${versionFileInput} as ${version}`);
9373393739 }
9373493740 return version;
@@ -93783,9 +93789,25 @@ function parseNodeVersionFile(contents) {
9378393789 let nodeVersion;
9378493790 // Try parsing the file as an NPM `package.json` file.
9378593791 try {
93786- nodeVersion = (_a = JSON.parse(contents).volta) === null || _a === void 0 ? void 0 : _a.node;
93787- if (!nodeVersion)
93788- nodeVersion = (_b = JSON.parse(contents).engines) === null || _b === void 0 ? void 0 : _b.node;
93792+ const manifest = JSON.parse(contents);
93793+ // JSON can parse numbers, but that's handled later
93794+ if (typeof manifest === 'object') {
93795+ nodeVersion = (_a = manifest.volta) === null || _a === void 0 ? void 0 : _a.node;
93796+ if (!nodeVersion)
93797+ nodeVersion = (_b = manifest.engines) === null || _b === void 0 ? void 0 : _b.node;
93798+ // if contents are an object, we parsed JSON
93799+ // this can happen if node-version-file is a package.json
93800+ // yet contains no volta.node or engines.node
93801+ //
93802+ // if node-version file is _not_ json, control flow
93803+ // will not have reached these lines.
93804+ //
93805+ // And because we've reached here, we know the contents
93806+ // *are* JSON, so no further string parsing makes sense.
93807+ if (!nodeVersion) {
93808+ return null;
93809+ }
93810+ }
9378993811 }
9379093812 catch (_d) {
9379193813 core.info('Node version file is not JSON file');
0 commit comments