mirror of
https://github.com/actions/setup-node.git
synced 2025-06-28 05:33:47 +00:00
test: adjust for array like devEngines
Co-authored-by: Grigory <grigory.orlov.set@gmail.com> Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
88483fd687
commit
25df5cda4f
6 changed files with 61 additions and 24 deletions
14
src/util.ts
14
src/util.ts
|
@ -27,11 +27,15 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
|||
}
|
||||
|
||||
// support devEngines from npm 11
|
||||
if (
|
||||
manifest.devEngines?.runtime?.name === 'node' &&
|
||||
manifest.devEngines.runtime.version
|
||||
) {
|
||||
return manifest.devEngines.runtime.version;
|
||||
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue