mirror of
https://github.com/actions/setup-node.git
synced 2025-04-22 03:28:42 +00:00
Add ability to use package json version.
This will only work with top level package json file and not nested files.
This commit is contained in:
parent
146c4d84a5
commit
b59618b1f6
1 changed files with 12 additions and 0 deletions
12
src/main.ts
12
src/main.ts
|
@ -72,6 +72,18 @@ function resolveVersionInput(): string {
|
|||
'Both node-version and node-version-file inputs are specified, only node-version will be used'
|
||||
);
|
||||
}
|
||||
|
||||
if (version === "package") {
|
||||
const packageJson = JSON.parse(
|
||||
fs.readFileSync(
|
||||
path.join(
|
||||
process.env.GITHUB_WORKSPACE!,
|
||||
"package.json"
|
||||
)
|
||||
)
|
||||
);
|
||||
return packageJson.engines.node;
|
||||
}
|
||||
|
||||
if (version) {
|
||||
return version;
|
||||
|
|
Loading…
Add table
Reference in a new issue