This commit is contained in:
桌子潔 2026-08-12 18:14:19 -05:00 • committed by GitHub
commit f11713bc04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 73 additions and 6 deletions

View file

@ -92809,8 +92809,19 @@ function getNodeVersionFromFile(versionFilePath) {
catch {
core.info('Node version file is not JSON file');
}
const found = contents.match(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m);
return found?.groups?.version ?? contents.trim();
let versionFileContents = contents;
if (path.basename(versionFilePath) === '.nvmrc') {
versionFileContents = contents
.split(/\r?\n/)
.map(line => line.replace(/#.*/, '').trim())
.filter(Boolean)
.join('\n');
if (!versionFileContents) {
return null;
}
}
const found = versionFileContents.match(/^(?:node(js)?\s+)?v?(?<version>[^\s]+)$/m);
return found?.groups?.version ?? versionFileContents.trim();
}
async function printEnvDetailsAndSetOutput() {
core.startGroup('Environment details');