Description
Currently the behavior is that node-version is preferred rather than node-version-file if both are provided.
|
if (version && versionFileInput) { |
|
core.warning( |
|
'Both node-version and node-version-file inputs are specified, only node-version will be used' |
|
); |
|
} |
|
|
|
if (version) { |
|
return version; |
|
} |
|
|
|
if (versionFileInput) { |
I would like to propose the opposite since node-version is actually hardcoded in the action parameters, but the file is not guaranteed to be there.
|
if (!fs.existsSync(versionFilePath)) { |
|
throw new Error( |
|
`The specified node version file at: ${versionFilePath} does not exist` |
|
); |
|
} |
Currently, scenarios resolved as following:
with:
node-version: 8 # nothing to see here
with:
node-version-file: fileExists.json # all good
with:
node-version-file: fileDoesNotExists.json # throws error and crashes the pipeline
with:
node-version: 8
node-version-file: fileExists.json # ignored, picked version is 8
with:
node-version: 8
node-version-file: fileDoesNotExists.json # ignored, picked version is 8
What I'm requesting for is a change in the 2 lasts scenarios:
with:
node-version: 8
node-version-file: fileExists.json # has priority, so it's picked
with:
node-version: 8
node-version-file: fileDoesNotExists.json # does not throw and picks version 8 instead
Justification
This is just a nicer API, i think. it does not remove the case of conscious crash of the pipeline if no node-version is given, but it does nicely propose a fail-safe for people interested.
Note
We could also have another parameter such as node-version-fallback-if-file-not-found but it'd just increase the complexity of the api.
Are you willing to submit a PR?
Yes, i'm ok with that.
Description
Currently the behavior is that
node-versionis preferred rather thannode-version-fileif both are provided.setup-node/src/main.ts
Lines 85 to 95 in d86ebcd
I would like to propose the opposite since
node-versionis actually hardcoded in the action parameters, but the file is not guaranteed to be there.setup-node/src/util.ts
Lines 8 to 12 in d86ebcd
Currently, scenarios resolved as following:
What I'm requesting for is a change in the 2 lasts scenarios:
Justification
This is just a nicer API, i think. it does not remove the case of conscious crash of the pipeline if no
node-versionis given, but it does nicely propose a fail-safe for people interested.Note
We could also have another parameter such as
node-version-fallback-if-file-not-foundbut it'd just increase the complexity of the api.Are you willing to submit a PR?
Yes, i'm ok with that.