GeezerVison is showing github.com — Respect `package.json`'s `engines.node` field when used as a `node-version-file` by mannie-exe · Pull Request #485 · actions/setup-node
Respect package.json's engines.node field when used as a node-version-file#485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
@@ -495,16 +495,26 @@ function translateArchToDistUrl(arch: string): string {
}
export function parseNodeVersionFile(contents: string): string {
let nodeVersion: string | undefined;
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
const nodeVersion = found?.groups?.version;
nodeVersion = found?.groups?.version;
if (!nodeVersion) {
try {
// Try parsing the file as an NPM `package.json`
// file.
nodeVersion = JSON.parse(contents).engines?.node;
if (nodeVersion) {
return nodeVersion;
if (!nodeVersion) throw new Error();
} catch (err) {
// In the case of an unknown format,
// return as is and evaluate the version separately.
nodeVersion = contents.trim();
}
}
// In the case of an unknown format,
// return as is and evaluate the version separately.
return contents.trim();
return nodeVersion as string;
}
function isLatestSyntax(versionSpec): boolean {
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.