refactor: move volta logic

This commit is contained in:
Jef LeCompte 2022-06-29 15:37:53 -07:00
parent 9aa86428fe
commit dbfbe9b6da
No known key found for this signature in database
GPG key ID: 7F5BA322B5DC170C
4 changed files with 40 additions and 24 deletions

View file

@ -65,9 +65,7 @@ export async function run() {
function resolveVersionInput(): string {
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(
@ -91,13 +89,9 @@ function resolveVersionInput(): string {
);
}
if (nodeVersionFile === 'volta') {
version = JSON.parse(fs.readFileSync(versionFilePath, 'utf8')).volta.node;
} else {
version = installer.parseNodeVersionFile(
fs.readFileSync(versionFilePath, 'utf8')
);
}
version = installer.parseNodeVersionFile(
fs.readFileSync(versionFilePath, 'utf8')
);
core.info(`Resolved ${versionFileInput} as ${version}`);
}