From d8469e87d542dda164c704aa28a0dc59175679ef Mon Sep 17 00:00:00 2001 From: Gustavo Perdomo Date: Wed, 22 Oct 2025 00:25:58 -0300 Subject: [PATCH] feat: add support for mise.toml file --- __tests__/main.test.ts | 3 +++ dist/cache-save/index.js | 7 +++++-- dist/setup/index.js | 7 +++++-- src/util.ts | 8 ++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 0af507b8..e2f90be8 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -114,6 +114,9 @@ describe('main tests', () => { ${'{"devEngines": {"runtime": [{"name": "bun"}, {"name": "node", "version": "22.0.0"}]}}'} | ${'22.0.0'} ${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'} ${'[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}) => { const existsSpy = jest.spyOn(fs, 'existsSync'); existsSpy.mockImplementation(() => true); diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index f8c6b99d..efc3186f 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -50602,7 +50602,7 @@ function getNodeVersionFromFile(versionFilePath) { catch { 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 { const manifest = (0, js_toml_1.load)(contents); if (manifest?.tools?.node) { @@ -50610,7 +50610,10 @@ function getNodeVersionFromFile(versionFilePath) { if (typeof node === 'object' && node?.version) { return node.version; } - return node; + if (typeof node === 'string') { + return node; + } + return null; } } catch { diff --git a/dist/setup/index.js b/dist/setup/index.js index 772c52b1..5c26a3dc 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -84097,7 +84097,7 @@ function getNodeVersionFromFile(versionFilePath) { catch { 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 { const manifest = (0, js_toml_1.load)(contents); if (manifest?.tools?.node) { @@ -84105,7 +84105,10 @@ function getNodeVersionFromFile(versionFilePath) { if (typeof node === 'object' && node?.version) { return node.version; } - return node; + if (typeof node === 'string') { + return node; + } + return null; } } catch { diff --git a/src/util.ts b/src/util.ts index 5eaf1b52..2575f9bc 100644 --- a/src/util.ts +++ b/src/util.ts @@ -69,7 +69,7 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null { 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 { const manifest: Record = load(contents); if (manifest?.tools?.node) { @@ -79,7 +79,11 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null { return node.version; } - return node; + if (typeof node === 'string') { + return node; + } + + return null; } } catch { core.info('Node version file is not TOML file');