mirror of
https://github.com/actions/setup-node.git
synced 2026-02-27 01:34:43 +08:00
feat(node-version-file): support parsing devEngines field (#1283)
* feat(node-version-file): support parsing `devEngines` field Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> * test: adjust for array like `devEngines` Co-authored-by: Grigory <grigory.orlov.set@gmail.com> Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> * ci(versions.yml): update actions and reduce duplicated tests Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> * docs: consolidate advanced usage Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> * chore: compile assets Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> --------- Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> Co-authored-by: Grigory <grigory.orlov.set@gmail.com>
This commit is contained in:
committed by
GitHub
parent
efcb663fc6
commit
774c1d6296
12
src/util.ts
12
src/util.ts
@@ -26,6 +26,18 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
||||
return manifest.volta.node;
|
||||
}
|
||||
|
||||
// support devEngines from npm 11
|
||||
if (manifest.devEngines?.runtime) {
|
||||
// find an entry with name set to node and having set a version.
|
||||
// the devEngines.runtime can either be an object or an array of objects
|
||||
const nodeEntry = [manifest.devEngines.runtime]
|
||||
.flat()
|
||||
.find(({name, version}) => name?.toLowerCase() === 'node' && version);
|
||||
if (nodeEntry) {
|
||||
return nodeEntry.version;
|
||||
}
|
||||
}
|
||||
|
||||
if (manifest.engines?.node) {
|
||||
return manifest.engines.node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user