mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-19 21:04:45 +00:00
refactor: move volta logic
This commit is contained in:
parent
9aa86428fe
commit
dbfbe9b6da
4 changed files with 40 additions and 24 deletions
18
dist/setup/index.js
vendored
18
dist/setup/index.js
vendored
|
@ -71768,7 +71768,13 @@ function translateArchToDistUrl(arch) {
|
|||
}
|
||||
}
|
||||
function parseNodeVersionFile(contents) {
|
||||
let nodeVersion = contents.trim();
|
||||
let nodeVersion;
|
||||
if (contents.includes('volta')) {
|
||||
nodeVersion = JSON.parse(contents).volta.node;
|
||||
}
|
||||
else {
|
||||
nodeVersion = contents.trim();
|
||||
}
|
||||
if (/^v\d/.test(nodeVersion)) {
|
||||
nodeVersion = nodeVersion.substring(1);
|
||||
}
|
||||
|
@ -71862,8 +71868,7 @@ function run() {
|
|||
exports.run = run;
|
||||
function resolveVersionInput() {
|
||||
let version = core.getInput('node-version');
|
||||
const nodeVersionFile = core.getInput('node-version-file');
|
||||
const versionFileInput = nodeVersionFile === 'volta' ? 'package.json' : nodeVersionFile;
|
||||
const versionFileInput = core.getInput('node-version-file');
|
||||
if (version && versionFileInput) {
|
||||
core.warning('Both node-version and node-version-file inputs are specified, only node-version will be used');
|
||||
}
|
||||
|
@ -71875,12 +71880,7 @@ function resolveVersionInput() {
|
|||
if (!fs_1.default.existsSync(versionFilePath)) {
|
||||
throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
|
||||
}
|
||||
if (nodeVersionFile === 'volta') {
|
||||
version = JSON.parse(fs_1.default.readFileSync(versionFilePath, 'utf8')).volta.node;
|
||||
}
|
||||
else {
|
||||
version = installer.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
|
||||
}
|
||||
version = installer.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
|
||||
core.info(`Resolved ${versionFileInput} as ${version}`);
|
||||
}
|
||||
return version;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue