Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use package json version. #469

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main.ts
Expand Up @@ -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!,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
process.env.GITHUB_WORKSPACE!,
process.env.GITHUB_WORKSPACE,

I think we should use node-version-file or similar here to support package.json in subdirectory.

Besides, is the version definition format in package.json (it includes eg. version ranges) the same as expected here or we have to resolve it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea behind this is for people who have a fixed node version. So doesn't need to interpret anything other than the value. Also I copied the code from above in the file so don't think it requires changing

"package.json"
)
)
);
return packageJson.engines.node;
}

if (version) {
return version;
Expand Down