feat: add volta as node-version-file
This commit is contained in:
parent
7d610f0c26
commit
1a4ff5493d
|
@ -71862,7 +71862,8 @@ function run() {
|
|||
exports.run = run;
|
||||
function resolveVersionInput() {
|
||||
let version = core.getInput('node-version');
|
||||
const versionFileInput = core.getInput('node-version-file');
|
||||
const nodeVersionFile = core.getInput('node-version-file');
|
||||
const versionFileInput = nodeVersionFile === 'volta' ? 'package.json' : nodeVersionFile;
|
||||
if (version && versionFileInput) {
|
||||
core.warning('Both node-version and node-version-file inputs are specified, only node-version will be used');
|
||||
}
|
||||
|
@ -71874,7 +71875,12 @@ function resolveVersionInput() {
|
|||
if (!fs_1.default.existsSync(versionFilePath)) {
|
||||
throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
|
||||
}
|
||||
version = installer.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
|
||||
if (nodeVersionFile === 'volta') {
|
||||
version = JSON.parse(fs_1.default.readFileSync(versionFilePath, 'utf8')).volta.node;
|
||||
}
|
||||
else {
|
||||
version = installer.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
|
||||
}
|
||||
core.info(`Resolved ${versionFileInput} as ${version}`);
|
||||
}
|
||||
return version;
|
||||
|
|
17
src/main.ts
17
src/main.ts
|
@ -65,7 +65,9 @@ export async function run() {
|
|||
|
||||
function resolveVersionInput(): string {
|
||||
let version = core.getInput('node-version');
|
||||
const versionFileInput = core.getInput('node-version-file');
|
||||
const nodeVersionFile = core.getInput('node-version-file');
|
||||
const versionFileInput =
|
||||
nodeVersionFile === 'volta' ? 'package.json' : nodeVersionFile;
|
||||
|
||||
if (version && versionFileInput) {
|
||||
core.warning(
|
||||
|
@ -82,14 +84,21 @@ function resolveVersionInput(): string {
|
|||
process.env.GITHUB_WORKSPACE!,
|
||||
versionFileInput
|
||||
);
|
||||
|
||||
if (!fs.existsSync(versionFilePath)) {
|
||||
throw new Error(
|
||||
`The specified node version file at: ${versionFilePath} does not exist`
|
||||
);
|
||||
}
|
||||
version = installer.parseNodeVersionFile(
|
||||
fs.readFileSync(versionFilePath, 'utf8')
|
||||
);
|
||||
|
||||
if (nodeVersionFile === 'volta') {
|
||||
version = JSON.parse(fs.readFileSync(versionFilePath, 'utf8')).volta.node;
|
||||
} else {
|
||||
version = installer.parseNodeVersionFile(
|
||||
fs.readFileSync(versionFilePath, 'utf8')
|
||||
);
|
||||
}
|
||||
|
||||
core.info(`Resolved ${versionFileInput} as ${version}`);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
"sourceMap": true,
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
},
|
||||
"exclude": ["__tests__", "lib", "node_modules"]
|
||||
|
|
Loading…
Reference in New Issue