GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Read version from .nvmrc or .tool-versions config by matoakley · Pull Request #222 · actions/setup-node Conversation
|
| return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; | ||
| } | ||
| function parseNodeVersion() { | ||
| let nodeVersion = core.getInput('node-version') || core.getInput('version'); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
just wanted to ask here whether you want to check for a falsy value or just null or undefined? If the latter:
| let nodeVersion = core.getInput('node-version') || core.getInput('version'); | |
| let nodeVersion = core.getInput('node-version') ?? core.getInput('version'); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const nodeLine = toolVersions | ||
| .split(/\r?\n/) | ||
| .filter(e => e.match(/^nodejs\s/))[0]; | ||
| nodeVersion = nodeLine.match(/^nodejs\s+(.+)$/)![1]; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
.match() returns RegExpMatchArray | null, so rather than using definite assignment assertion (!), perhaps use the optional chain (?) to query the RegExpMatchArray. If nothing is returned here, it will assign undefined to nodeVersion.
This does then throw into question the flow of these statements, because if I have a .tool-versions with the nodejs key in (I think that's what you're testing?) but no value, then it will return undefined.
I would revisit this by allowing TS to guide you with the types & then making sure that a string is definitely being returned.
| nodeVersion = nodeLine.match(/^nodejs\s+(.+)$/)![1]; | |
| nodeVersion = nodeLine.match(/^nodejs\s+(.+)$/)?.[1]; |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks like a dupe of #209 ? Just commenting since it's highly related: https://github.com/nodenv/actions-node-version is an action that reads .node-version file (leveraging nodenv) and exposes it as an output that can be used as an input to the setup-node action. This would be a workaround until/unless setup-node gains the ability to do it automatically. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@matoakley @jamiehaywood Is there anything I can do to complete this feature? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@ruscon unfortunately I'm not a maintainer, I just added a review because I'm keen to get this feature into |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
this solution is better |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jamiehaywood Thanks for the review it's much appreciated 👍 Sadly I've lost hope on this PR given that the project appears to be all but abandoned by its maintainers. As has been pointed out, there are now at least 3 open PRs offering a solution to this problem and there seems to be high demand for the feature. @ruscon I agree that #239 would probably be a better all-round solution but whether it is "better" is subjective. For example, it wouldn't have solved my problem as the patch does not lookup the In the 3 months since I submitted this PR I have migrated my development environment to Docker and have resigned myself to managing the Node version manually for Github Actions. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.