()
| 101 | } |
| 102 | |
| 103 | function resolveVersionInput(): string { |
| 104 | let version = core.getInput('node-version'); |
| 105 | const versionFileInput = core.getInput('node-version-file'); |
| 106 | |
| 107 | if (version && versionFileInput) { |
| 108 | core.warning( |
| 109 | 'Both node-version and node-version-file inputs are specified, only node-version will be used' |
| 110 | ); |
| 111 | } |
| 112 | |
| 113 | if (version) { |
| 114 | return version; |
| 115 | } |
| 116 | |
| 117 | if (versionFileInput) { |
| 118 | const versionFilePath = path.join( |
| 119 | process.env.GITHUB_WORKSPACE!, |
| 120 | versionFileInput |
| 121 | ); |
| 122 | |
| 123 | const parsedVersion = getNodeVersionFromFile(versionFilePath); |
| 124 | |
| 125 | if (parsedVersion) { |
| 126 | version = parsedVersion; |
| 127 | } else { |
| 128 | core.warning( |
| 129 | `Could not determine node version from ${versionFilePath}. Falling back` |
| 130 | ); |
| 131 | } |
| 132 | |
| 133 | core.info(`Resolved ${versionFileInput} as ${version}`); |
| 134 | } |
| 135 | |
| 136 | return version; |
| 137 | } |
| 138 | |
| 139 | export function getNameFromPackageManagerField(): string | undefined { |
| 140 | const npmRegex = /^(\^)?npm(@.*)?$/; // matches "npm", "npm@...", "^npm@..." |
no test coverage detected