hokaccha / nodebrew

Node.js version manager
MIT License
1.06k stars 66 forks source link

nodebrew exec (idea) #25

Closed hokaccha closed 10 years ago

hokaccha commented 11 years ago

e.g.

$ nodebrew ls
v0.8.18
v0.10.12

current: v0.8.18

Current using version is v0.8.18, but I'd lile to run on v0.10.12 temporarily.

# exec subcommand can set version and any command.
$ nodebrew exec v0.10.12 -- node -v
v0.10.12

# run app.js
$ nodebrew exec v0.10.12 -- node app.js

# use global installed command
$ nodebrew exec v0.10.12 -- grunt

# read version from the `.nodebrew_version` file
$ cat .nodebrew_version
v0.10.12
$ nodebrew exec -- node -v
v0.10.12

Implementation idea.

$ENV{PATH} = "$brew_dir/node/$version/bin:$ENV{PATH}"
system($command); # same as ~/.nodebrew/node/v0.10.12/bin/node app.js