Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -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;