From b59618b1f6b7702880e0479b62858d73fa7a1b78 Mon Sep 17 00:00:00 2001 From: Andy Wilson <31218527+The-Code-Monkey@users.noreply.github.com> Date: Tue, 19 Apr 2022 09:51:31 +0100 Subject: [PATCH] Add ability to use package json version. This will only work with top level package json file and not nested files. --- src/main.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.ts b/src/main.ts index 3c5661b55..f4ad14418 100644 --- a/src/main.ts +++ b/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;