Closed JoshuaKGoldberg closed 5 months ago
Is there a .nvmrc
spec?
Or at least some example so that we can add some test cases?
I don't think there's a formal spec, no. Parsing of .nvmrc
comes from commands in https://github.com/nvm-sh/nvm/blob/6c9cd2f2d1779b91c0ab7ab0b243c0c55f25a8a5/nvm.sh. Filed https://github.com/nvm-sh/nvm/issues/3265.
For now, node -v
is the rough format it uses: an optional v
, a number, then 0-1 of .
and more numbers.
20
v20
v20.1
v20.12
v20.1.2
v20.1.23
v20.1.234
v20.12.2
v20.12.34
v20.12.345
Trailing ~whitespace and/or~ newlines seem to be fine as well.
https://github.com/JoshuaKGoldberg/create-typescript-app/blob/c91ce25e556f67ea321cd0df260a08569e71d8f8/.nvmrc is an example of a working file.
20.11.0
I'm not for sure to understand the user case here, this file is already lean enough to me? Is there any chance that can be not pretty?
Extra newlines after the version are allowed:
20.11.0
Playing around with it a bit more, it looks like whitespace on the same line are being parsed as the version number. So those can't be removed. But the following are ignored:
v
So this is actually a totally valid .nvmrc
:
20.11.0
...gotcha!
...now that I've played with this a bit more, maybe it deserves its own plugin?
...now that I've played with this a bit more, maybe it deserves its own plugin?
🤣 Still don't quite understand what's the text after first line does.
20.11.0 ...gotcha!
It's just valid, but not useful at all? Is there anyone really doing this?
Haha yeah it's just ignored. I've never seen it in the wild and didn't even think to try it out until after we started talking!
If you only want to trim, I think maybe it could be added, with a reference doc. Would you like to raise a PR?
Coming over here from https://github.com/prettier/prettier/issues/15898#issuecomment-1883395232: I'd like to use
prettier-plugin-sh
to format.nvmrc
files. Given that the plugin supports similar files (gitignore
,dotenv
, ...), is this a reasonable use case for the plugin?