Git Product home page Git Product logo

Comments (8)

isaacs avatar isaacs commented on June 16, 2024

Hmm it'd have to be something other than $NAVENAME, since that's load bearing to determine whether you're in a symlinked named env or direct in the version folder. But it should be straightforward to add a new env, and I can see the value in it. Maybe $NAVEARG?

from nave.

rulatir avatar rulatir commented on June 16, 2024

So if I add a named environment and say nave use my-named-env bash -c 'echo $NAVENAME', it will say 'my-named-env'?

from nave.

isaacs avatar isaacs commented on June 16, 2024

Yup!

$ nave use my-named-env 16 bash -c 'echo $NAVENAME'
Creating new env named 'my-named-env' using node 16.19.0
my-named-env

from nave.

isaacs avatar isaacs commented on June 16, 2024

Once it's created, you don't have to specify a version (or you don't have to initially, but it'll prompt you if it doesn't exist already). So, if it doesn't exist, it's not 100% headless (though you can echo $version | ... and that'll answer the prompt.)

Also, nave use <name> is a little bit clever, idk if it's clear from the example above. If the first argument is a valid node semver argument (like 18.0.1 or 16.3) then it'll create/update the named env to use that. Otherwise, it treats all remaining arguments as a command to run.

$ nave use my-named-env bash -c 'echo $NAVENAME'
my-named-env

$ nave use named-env-that-does-not-exist-yet bash -c 'echo $NAVENAME'
What version of node?
lts, lts/<name>, latest, x.y, or x.y.z > 16
Creating new env named 'named-env-that-does-not-exist-yet' using node 16.19.0
named-env-that-does-not-exist-yet

from nave.

isaacs avatar isaacs commented on June 16, 2024

Shipped 3.5.0, which now sets $NAVEVERSIONARG to the raw version argument provided.

In the case of nave use named-env without supplying a version, it is set to the resulting full version, because at least that way it's reliably set to something that we know would resolve to the version in use.

One weird side effect of this is that if you don't supply a version, and the named env doesn't yet exist, then it'll prompt the user for an argument but will not set $NAVEVERSIONARG to that argument. It'd be a bit of refactoring to capture that input in a way that the caller of add_named_env can get at it, and I figured it's enough of an edge case to not be worth it, but if you'd like to have that consistency, feel free to open a new issue on it.

from nave.

isaacs avatar isaacs commented on June 16, 2024

eg:

$ nave use new-named-env bash -c 'echo nva=$NAVEVERSIONARG'
What version of node? 16
Creating new env named 'new-named-env' using node 16.19.0
nva=16.19.0   # <-- would expect "16" here, not "16.19.0"

from nave.

rulatir avatar rulatir commented on June 16, 2024

In the case of nave use named-env without supplying a version, it is set to the resulting full version

If it is reliably set the original version argument given to nave use in every context in which the resolution is unambiguous, then that's fine. I can make sure that the resolution is unambiguous. Thanks!

from nave.

isaacs avatar isaacs commented on June 16, 2024

The issue is that the argument isn't stored anywhere after the first setup command. So all we know at the point of nave use named is whatever version it resolved to.

from nave.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.