feat: add support for mise.toml file

This commit is contained in:
Gustavo Perdomo 2025-10-22 00:13:35 -03:00
parent 633bb92bc0
commit d721415790
No known key found for this signature in database
7 changed files with 21488 additions and 1371 deletions

View file

@ -1,6 +1,7 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as io from '@actions/io';
import {load} from 'js-toml';
import fs from 'fs';
import path from 'path';
@ -56,6 +57,22 @@ 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 {
const manifest: Record<string, any> = load(contents);
if (manifest?.tools?.node) {
const node = manifest.tools.node;
if (typeof node === 'object' && node?.version) {
return node.version;
}
return node;
}
} catch {
core.info('Node version file is not TOML file');
}
const found = contents.match(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m);
return found?.groups?.version ?? contents.trim();
}