mirror of
https://gitea.com/actions/setup-node.git
synced 2026-02-25 17:05:45 +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
11
__tests__/data/package-dev-engines.json
Normal file
11
__tests__/data/package-dev-engines.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"engines": {
|
||||
"node": "^19"
|
||||
},
|
||||
"devEngines": {
|
||||
"runtime": {
|
||||
"name": "node",
|
||||
"version": "^20"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,22 +94,24 @@ describe('main tests', () => {
|
||||
|
||||
describe('getNodeVersionFromFile', () => {
|
||||
each`
|
||||
contents | expected
|
||||
${'12'} | ${'12'}
|
||||
${'12.3'} | ${'12.3'}
|
||||
${'12.3.4'} | ${'12.3.4'}
|
||||
${'v12.3.4'} | ${'12.3.4'}
|
||||
${'lts/erbium'} | ${'lts/erbium'}
|
||||
${'lts/*'} | ${'lts/*'}
|
||||
${'nodejs 12.3.4'} | ${'12.3.4'}
|
||||
${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'}
|
||||
${''} | ${''}
|
||||
${'unknown format'} | ${'unknown format'}
|
||||
${' 14.1.0 '} | ${'14.1.0'}
|
||||
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'}| ${'>=14.0.0 <=17.0.0'}
|
||||
${'{"volta": {"extends": "./package.json"}}'}| ${'18.0.0'}
|
||||
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
||||
${'{}'} | ${null}
|
||||
contents | expected
|
||||
${'12'} | ${'12'}
|
||||
${'12.3'} | ${'12.3'}
|
||||
${'12.3.4'} | ${'12.3.4'}
|
||||
${'v12.3.4'} | ${'12.3.4'}
|
||||
${'lts/erbium'} | ${'lts/erbium'}
|
||||
${'lts/*'} | ${'lts/*'}
|
||||
${'nodejs 12.3.4'} | ${'12.3.4'}
|
||||
${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'}
|
||||
${''} | ${''}
|
||||
${'unknown format'} | ${'unknown format'}
|
||||
${' 14.1.0 '} | ${'14.1.0'}
|
||||
${'{}'} | ${null}
|
||||
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'} | ${'>=14.0.0 <=17.0.0'}
|
||||
${'{"volta": {"extends": "./package.json"}}'} | ${'18.0.0'}
|
||||
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
||||
${'{"devEngines": {"runtime": {"name": "node", "version": "22.0.0"}}}'} | ${'22.0.0'}
|
||||
${'{"devEngines": {"runtime": [{"name": "bun"}, {"name": "node", "version": "22.0.0"}]}}'} | ${'22.0.0'}
|
||||
`.it('parses "$contents"', ({contents, expected}) => {
|
||||
const existsSpy = jest.spyOn(fs, 'existsSync');
|
||||
existsSpy.mockImplementation(() => true);
|
||||
|
||||
Reference in New Issue
Block a user