Skip to content

Commit 704063d

Browse files
committed
npm run build
1 parent 761ed2f commit 704063d

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

dist/cache-save/index.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83329,9 +83329,25 @@ function parseNodeVersionFile(contents) {
8332983329
let nodeVersion;
8333083330
// Try parsing the file as an NPM `package.json` file.
8333183331
try {
83332-
nodeVersion = (_a = JSON.parse(contents).volta) === null || _a === void 0 ? void 0 : _a.node;
83333-
if (!nodeVersion)
83334-
nodeVersion = (_b = JSON.parse(contents).engines) === null || _b === void 0 ? void 0 : _b.node;
83332+
const manifest = JSON.parse(contents);
83333+
// JSON can parse numbers, but that's handled later
83334+
if (typeof manifest === 'object') {
83335+
nodeVersion = (_a = manifest.volta) === null || _a === void 0 ? void 0 : _a.node;
83336+
if (!nodeVersion)
83337+
nodeVersion = (_b = manifest.engines) === null || _b === void 0 ? void 0 : _b.node;
83338+
// if contents are an object, we parsed JSON
83339+
// this can happen if node-version-file is a package.json
83340+
// yet contains no volta.node or engines.node
83341+
//
83342+
// if node-version file is _not_ json, control flow
83343+
// will not have reached these lines.
83344+
//
83345+
// And because we've reached here, we know the contents
83346+
// *are* JSON, so no further string parsing makes sense.
83347+
if (!nodeVersion) {
83348+
return null;
83349+
}
83350+
}
8333583351
}
8333683352
catch (_d) {
8333783353
core.info('Node version file is not JSON file');

dist/setup/index.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)