Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to explicitly choose .nvmrc or engines.node #37

Closed
1 of 2 tasks
ericcornelissen opened this issue Jun 1, 2023 · 4 comments
Closed
1 of 2 tasks

Add option to explicitly choose .nvmrc or engines.node #37

ericcornelissen opened this issue Jun 1, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@ericcornelissen
Copy link

Guidelines

  • Please search other issues to make sure this feature has not already been requested.

Which problem is this feature request solving?

Currently, the local option works as:

# Run the current directory's Node.js version using its `.nvmrc` or `package.json` (`engines.node` field)
$ nve local npm test

which, based on testing, in practice first looks for .nvmrc and uses that (even if package.json#engines.node is present) and then looks at package.json#engines.node to choose a Node.js version.

In library projects I use both of these, but for different purposes. package.json#engines.node is there to tell users of the library which versions of Node.js the library promises to work in. .nvmrc is used to specify the version of Node.js that should be used during development (to make sure all development dependencies work).

With nve local I can't choose which one I want to use (plus it's not clear which one will be used). But I would like to use something like nve local to avoid repeating what's in (in my particular case) package.json#engines.node.

Describe the solution you'd like

Either a flag or new subcommand to be able to explicitly select the local source to use for the Node.js version.

Some ideas:

# Using a flag with "local"
$ nve local --source .nvmrc npm test
$ nve local --source package.json npm test

# Using a new subcommand
$ nve nvmrc npm test
$ nve package.json npm test
$ nve engines npm test

I'd personally deprecate nve local since it's ambiguous, but that decision up to the maintainers of the project 🙂

Pull request (optional)

  • I can submit a pull request.
@ericcornelissen ericcornelissen added the enhancement New feature or request label Jun 1, 2023
@ehmicky
Copy link
Owner

ehmicky commented Jul 13, 2023

Hi @ericcornelissen,

This is a good idea, thanks for sharing.

A solution is now available in 16.1.0. It is similar to the --source flag you suggested but with a different syntax. Namely, instead of using a version number, nve now accepts paths to version files like .nvmrc or package.json. For example, you can now run:

$ nve /path/to/package.json npm test

$ nve /path/to/.nvmrc npm test

// Or more advanced selections like this
$ nve --parallel package.json,.nvmrc,18,20 npm test

Thanks again for the idea.
@all-contributors Could you please add @ericcornelissen for ideas?

@allcontributors
Copy link
Contributor

@ehmicky

I've put up a pull request to add @thanks! 🎉

We had trouble processing your request. Please try again later.

@ehmicky
Copy link
Owner

ehmicky commented Jul 13, 2023

Oh all-contributors, you got that wrong. :) Lets try again.

@all-contributors Please add @ericcornelissen for ideas.

@allcontributors
Copy link
Contributor

@ehmicky

I've put up a pull request to add @ericcornelissen! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants