This commit is contained in:
Gustavo Perdomo 2026-02-20 10:11:40 -03:00 committed by GitHub
commit 5c26de102c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 86601 additions and 64757 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,26 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null {
core.info('Node version file is not JSON file');
}
// Try parsing the file as a 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;
}
if (typeof node === 'string') {
return node;
}
return null;
}
} 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();
}