mirror of
https://github.com/actions/setup-node.git
synced 2025-12-18 22:37:08 +00:00
feat: add support for mise.toml file
This commit is contained in:
parent
633bb92bc0
commit
d721415790
7 changed files with 21488 additions and 1371 deletions
17
src/util.ts
17
src/util.ts
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue