Skip to content

Commit d8469e8

Browse files
committed
feat: add support for mise.toml file
1 parent 86d7342 commit d8469e8

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

__tests__/main.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ describe('main tests', () => {
114114
${'{"devEngines": {"runtime": [{"name": "bun"}, {"name": "node", "version": "22.0.0"}]}}'} | ${'22.0.0'}
115115
${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'}
116116
${'[tools]\nnode = "22.12"'} | ${'22.12'}
117+
${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'}
118+
${'[tools]\nnode = { version = "22.20" }'} | ${'22.20'}
119+
${'[tools]\nnode = { postinstall = "corepack enable" }'} | ${null}
117120
`.it('parses "$contents"', ({contents, expected}) => {
118121
const existsSpy = jest.spyOn(fs, 'existsSync');
119122
existsSpy.mockImplementation(() => true);

dist/cache-save/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50602,15 +50602,18 @@ function getNodeVersionFromFile(versionFilePath) {
5060250602
catch {
5060350603
core.info('Node version file is not JSON file');
5060450604
}
50605-
// Try parsing the file as an MISE `mise.toml` file.
50605+
// Try parsing the file as a mise `mise.toml` file.
5060650606
try {
5060750607
const manifest = (0, js_toml_1.load)(contents);
5060850608
if (manifest?.tools?.node) {
5060950609
const node = manifest.tools.node;
5061050610
if (typeof node === 'object' && node?.version) {
5061150611
return node.version;
5061250612
}
50613-
return node;
50613+
if (typeof node === 'string') {
50614+
return node;
50615+
}
50616+
return null;
5061450617
}
5061550618
}
5061650619
catch {

dist/setup/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84097,15 +84097,18 @@ function getNodeVersionFromFile(versionFilePath) {
8409784097
catch {
8409884098
core.info('Node version file is not JSON file');
8409984099
}
84100-
// Try parsing the file as an MISE `mise.toml` file.
84100+
// Try parsing the file as a mise `mise.toml` file.
8410184101
try {
8410284102
const manifest = (0, js_toml_1.load)(contents);
8410384103
if (manifest?.tools?.node) {
8410484104
const node = manifest.tools.node;
8410584105
if (typeof node === 'object' && node?.version) {
8410684106
return node.version;
8410784107
}
84108-
return node;
84108+
if (typeof node === 'string') {
84109+
return node;
84110+
}
84111+
return null;
8410984112
}
8411084113
}
8411184114
catch {

src/util.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
6969
core.info('Node version file is not JSON file');
7070
}
7171

72-
// Try parsing the file as an MISE `mise.toml` file.
72+
// Try parsing the file as a mise `mise.toml` file.
7373
try {
7474
const manifest: Record<string, any> = load(contents);
7575
if (manifest?.tools?.node) {
@@ -79,7 +79,11 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
7979
return node.version;
8080
}
8181

82-
return node;
82+
if (typeof node === 'string') {
83+
return node;
84+
}
85+
86+
return null;
8387
}
8488
} catch {
8589
core.info('Node version file is not TOML file');

0 commit comments

Comments
 (0)