mirror of
https://github.com/actions/setup-node.git
synced 2026-03-01 06:41:05 +08:00
feat: add support for mise.toml file
This commit is contained in:
parent
58a435db40
commit
4f2b2fdc2b
@ -110,6 +110,8 @@ describe('main tests', () => {
|
|||||||
${'{"volta": {"extends": "./package.json"}}'} | ${'18.0.0'}
|
${'{"volta": {"extends": "./package.json"}}'} | ${'18.0.0'}
|
||||||
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
||||||
${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'}
|
${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'}
|
||||||
|
${'[tools]\nnode = { version = "22.20" }'} | ${'22.20'}
|
||||||
|
${'[tools]\nnode = { postinstall = "corepack enable" }'} | ${null}
|
||||||
${'{}'} | ${null}
|
${'{}'} | ${null}
|
||||||
`.it('parses "$contents"', ({contents, expected}) => {
|
`.it('parses "$contents"', ({contents, expected}) => {
|
||||||
const existsSpy = jest.spyOn(fs, 'existsSync');
|
const existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
|||||||
5
dist/cache-save/index.js
vendored
5
dist/cache-save/index.js
vendored
@ -75721,7 +75721,7 @@ function getNodeVersionFromFile(versionFilePath) {
|
|||||||
catch {
|
catch {
|
||||||
core.info('Node version file is not JSON file');
|
core.info('Node version file is not JSON file');
|
||||||
}
|
}
|
||||||
// Try parsing the file as an MISE `mise.toml` file.
|
// Try parsing the file as a mise `mise.toml` file.
|
||||||
try {
|
try {
|
||||||
const manifest = (0, js_toml_1.load)(contents);
|
const manifest = (0, js_toml_1.load)(contents);
|
||||||
if (manifest?.tools?.node) {
|
if (manifest?.tools?.node) {
|
||||||
@ -75729,8 +75729,11 @@ function getNodeVersionFromFile(versionFilePath) {
|
|||||||
if (typeof node === 'object' && node?.version) {
|
if (typeof node === 'object' && node?.version) {
|
||||||
return node.version;
|
return node.version;
|
||||||
}
|
}
|
||||||
|
if (typeof node === 'string') {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
core.info('Node version file is not TOML file');
|
core.info('Node version file is not TOML file');
|
||||||
|
|||||||
5
dist/setup/index.js
vendored
5
dist/setup/index.js
vendored
@ -86259,7 +86259,7 @@ function getNodeVersionFromFile(versionFilePath) {
|
|||||||
catch {
|
catch {
|
||||||
core.info('Node version file is not JSON file');
|
core.info('Node version file is not JSON file');
|
||||||
}
|
}
|
||||||
// Try parsing the file as an MISE `mise.toml` file.
|
// Try parsing the file as a mise `mise.toml` file.
|
||||||
try {
|
try {
|
||||||
const manifest = (0, js_toml_1.load)(contents);
|
const manifest = (0, js_toml_1.load)(contents);
|
||||||
if (manifest?.tools?.node) {
|
if (manifest?.tools?.node) {
|
||||||
@ -86267,8 +86267,11 @@ function getNodeVersionFromFile(versionFilePath) {
|
|||||||
if (typeof node === 'object' && node?.version) {
|
if (typeof node === 'object' && node?.version) {
|
||||||
return node.version;
|
return node.version;
|
||||||
}
|
}
|
||||||
|
if (typeof node === 'string') {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
core.info('Node version file is not TOML file');
|
core.info('Node version file is not TOML file');
|
||||||
|
|||||||
@ -57,7 +57,7 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
|||||||
core.info('Node version file is not JSON file');
|
core.info('Node version file is not JSON file');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try parsing the file as an MISE `mise.toml` file.
|
// Try parsing the file as a mise `mise.toml` file.
|
||||||
try {
|
try {
|
||||||
const manifest: Record<string, any> = load(contents);
|
const manifest: Record<string, any> = load(contents);
|
||||||
if (manifest?.tools?.node) {
|
if (manifest?.tools?.node) {
|
||||||
@ -67,8 +67,12 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
|
|||||||
return node.version;
|
return node.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof node === 'string') {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
core.info('Node version file is not TOML file');
|
core.info('Node version file is not TOML file');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user