feat: add support for mise.toml file

This commit is contained in:
Gustavo Perdomo 2025-10-22 00:25:58 -03:00
parent 86d7342e00
commit d8469e87d5
No known key found for this signature in database
4 changed files with 19 additions and 6 deletions

View File

@ -114,6 +114,9 @@ describe('main tests', () => {
${'{"devEngines": {"runtime": [{"name": "bun"}, {"name": "node", "version": "22.0.0"}]}}'} | ${'22.0.0'} ${'{"devEngines": {"runtime": [{"name": "bun"}, {"name": "node", "version": "22.0.0"}]}}'} | ${'22.0.0'}
${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'} ${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'}
${'[tools]\nnode = "22.12"'} | ${'22.12'} ${'[tools]\nnode = "22.12"'} | ${'22.12'}
${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'}
${'[tools]\nnode = { version = "22.20" }'} | ${'22.20'}
${'[tools]\nnode = { postinstall = "corepack enable" }'} | ${null}
`.it('parses "$contents"', ({contents, expected}) => { `.it('parses "$contents"', ({contents, expected}) => {
const existsSpy = jest.spyOn(fs, 'existsSync'); const existsSpy = jest.spyOn(fs, 'existsSync');
existsSpy.mockImplementation(() => true); existsSpy.mockImplementation(() => true);

View File

@ -50602,7 +50602,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) {
@ -50610,7 +50610,10 @@ function getNodeVersionFromFile(versionFilePath) {
if (typeof node === 'object' && node?.version) { if (typeof node === 'object' && node?.version) {
return node.version; return node.version;
} }
return node; if (typeof node === 'string') {
return node;
}
return null;
} }
} }
catch { catch {

7
dist/setup/index.js vendored
View File

@ -84097,7 +84097,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) {
@ -84105,7 +84105,10 @@ function getNodeVersionFromFile(versionFilePath) {
if (typeof node === 'object' && node?.version) { if (typeof node === 'object' && node?.version) {
return node.version; return node.version;
} }
return node; if (typeof node === 'string') {
return node;
}
return null;
} }
} }
catch { catch {

View File

@ -69,7 +69,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) {
@ -79,7 +79,11 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
return node.version; return node.version;
} }
return node; if (typeof node === 'string') {
return node;
}
return null;
} }
} catch { } catch {
core.info('Node version file is not TOML file'); core.info('Node version file is not TOML file');