mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-13 10:09:06 +00:00
Compare commits
236 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5686d9a3bb | ||
![]() |
49e9a309c3 | ||
![]() |
788d87774f | ||
![]() |
7ccc2dd5ed | ||
![]() |
7862182d6f | ||
![]() |
b4a9c14d4e | ||
![]() |
473dd86f48 | ||
![]() |
6e1c249ecd | ||
![]() |
d3f04c793e | ||
![]() |
ef7e3cc39a | ||
![]() |
e6116d96ab | ||
![]() |
5e2ad5bb8d | ||
![]() |
a7a91441aa | ||
![]() |
a2a8ddb779 | ||
![]() |
1ad9d18257 | ||
![]() |
e58c495f69 | ||
![]() |
676a2cc865 | ||
![]() |
c6f72953c9 | ||
![]() |
41352e866d | ||
![]() |
34a067647c | ||
![]() |
db3035c29b | ||
![]() |
01f8eef7a2 | ||
![]() |
e6d1d0c4de | ||
![]() |
d6fe38a356 | ||
![]() |
1478c72124 | ||
![]() |
8e8da23711 | ||
![]() |
62dec72394 | ||
![]() |
c2e4e1a8a7 | ||
![]() |
6a98d168b7 | ||
![]() |
8ce8bef249 | ||
![]() |
2b216ab5d1 | ||
![]() |
af105894d7 | ||
![]() |
e5d7d493b9 | ||
![]() |
e0bd3735f1 | ||
![]() |
81d731d355 | ||
![]() |
7fb6d1ec6a | ||
![]() |
6690aecc6c | ||
![]() |
137539cf48 | ||
![]() |
4a7945f8c1 | ||
![]() |
8b9c0b933c | ||
![]() |
8983644854 | ||
![]() |
39c5d0597d | ||
![]() |
ab71d50b3a | ||
![]() |
36ce8f0010 | ||
![]() |
c6cb1601f7 | ||
![]() |
be0b2926b3 | ||
![]() |
f8a6e23fa7 | ||
![]() |
1e353b2773 | ||
![]() |
9537db1a4a | ||
![]() |
e7e84ec376 | ||
![]() |
6a2d92bc51 | ||
![]() |
855d89bef0 | ||
![]() |
36843d97cb | ||
![]() |
c5437bb222 | ||
![]() |
d428bcd50e | ||
![]() |
f82cde11a9 | ||
![]() |
dc46a740a3 | ||
![]() |
93e84a2676 | ||
![]() |
5a4c097aac | ||
![]() |
5c6af59fcd | ||
![]() |
72fd8c970a | ||
![]() |
d1d53ea979 | ||
![]() |
04dba10b9a | ||
![]() |
8486a0da2b | ||
![]() |
b2b29ff5c5 | ||
![]() |
6c57b275db | ||
![]() |
7cc6f37e69 | ||
![]() |
0f05655ee6 | ||
![]() |
6b932e59c3 | ||
![]() |
9a8e66cfca | ||
![]() |
66633de1a9 | ||
![]() |
bc04ed3ece | ||
![]() |
9205ff8001 | ||
![]() |
367ae728fb | ||
![]() |
335456d008 | ||
![]() |
eade411422 | ||
![]() |
cca6edfc5c | ||
![]() |
42915fc21c | ||
![]() |
f1b484ee87 | ||
![]() |
6c3708d337 | ||
![]() |
91a7aa8611 | ||
![]() |
db7494494c | ||
![]() |
ca44bafff2 | ||
![]() |
01189e144c | ||
![]() |
3fe12f0a49 | ||
![]() |
e4acd63991 | ||
![]() |
3ce23aa726 | ||
![]() |
205117bed4 | ||
![]() |
9c7da6cec3 | ||
![]() |
1088b4b00f | ||
![]() |
5811cb9e73 | ||
![]() |
0ec339e040 | ||
![]() |
7226e5fb98 | ||
![]() |
bc9c82cb9f | ||
![]() |
f605581c7d | ||
![]() |
87a76af398 | ||
![]() |
70e1b81ad3 | ||
![]() |
e145978e73 | ||
![]() |
a6be969403 | ||
![]() |
184f641730 | ||
![]() |
7dc0827eaa | ||
![]() |
278fd031b0 | ||
![]() |
7013372867 | ||
![]() |
881178db01 | ||
![]() |
1845a4a5a9 | ||
![]() |
bc508802e5 | ||
![]() |
0a4d3a2944 | ||
![]() |
5596054445 | ||
![]() |
68f7dc9cb3 | ||
![]() |
9c3af112ca | ||
![]() |
eaf8a50483 | ||
![]() |
6c70627478 | ||
![]() |
dc2bf8c526 | ||
![]() |
b063b32642 | ||
![]() |
7bee39fd81 | ||
![]() |
2f6b0ca9d7 | ||
![]() |
2662840064 | ||
![]() |
1a08edd94e | ||
![]() |
59c8eda18c | ||
![]() |
0803e317e1 | ||
![]() |
1709fa9248 | ||
![]() |
3c4bf80ec7 | ||
![]() |
dd3650fc8f | ||
![]() |
4ffd4bb34f | ||
![]() |
d6ef9c8893 | ||
![]() |
21f00362b0 | ||
![]() |
f3bf583285 | ||
![]() |
a1d14ea5b8 | ||
![]() |
3b2d2e4b61 | ||
![]() |
03b16d7a67 | ||
![]() |
e1ec264b26 | ||
![]() |
182e28f1ae | ||
![]() |
5977a02e8b | ||
![]() |
ab16d34012 | ||
![]() |
c4a13dd2b6 | ||
![]() |
7c2dfda88d | ||
![]() |
1dbb7c799d | ||
![]() |
d9f25f8f58 | ||
![]() |
b73f0930cc | ||
![]() |
3766bff734 | ||
![]() |
304924a969 | ||
![]() |
a0c4229abe | ||
![]() |
eea0b05ece | ||
![]() |
a27d39139b | ||
![]() |
903479aeca | ||
![]() |
d8713bb2e8 | ||
![]() |
4a6c696074 | ||
![]() |
a368227237 | ||
![]() |
5a17b81a09 | ||
![]() |
e1be38f90d | ||
![]() |
80cf1159bb | ||
![]() |
9fb65cbf7b | ||
![]() |
693abf3173 | ||
![]() |
e755c47d5a | ||
![]() |
3d65d55b5a | ||
![]() |
6505c98461 | ||
![]() |
5af8cec6dc | ||
![]() |
ebff66649e | ||
![]() |
07aaa91c9b | ||
![]() |
a107b12d2a | ||
![]() |
a12b6d7dd6 | ||
![]() |
2adbe8bd7f | ||
![]() |
04652a5090 | ||
![]() |
d68c38902a | ||
![]() |
cd14416bfd | ||
![]() |
9190297d5e | ||
![]() |
ad5242ea0b | ||
![]() |
5132a1eb6f | ||
![]() |
3bb2634d2f | ||
![]() |
e475d7e7ab | ||
![]() |
cf00a067ca | ||
![]() |
f8c1822033 | ||
![]() |
7d4b12446a | ||
![]() |
96a4488732 | ||
![]() |
3dd6b29905 | ||
![]() |
91670abdca | ||
![]() |
d544d8e2eb | ||
![]() |
3e62657575 | ||
![]() |
c371a3a26b | ||
![]() |
cfa81b49d1 | ||
![]() |
6e50bc0d78 | ||
![]() |
6d58fcb8c0 | ||
![]() |
5eb95fd641 | ||
![]() |
cd7c58ff6a | ||
![]() |
a86262520a | ||
![]() |
60892c7b51 | ||
![]() |
0dd0224f2d | ||
![]() |
dcd29296e9 | ||
![]() |
45051f4d43 | ||
![]() |
7c3af21ebe | ||
![]() |
293061b8b7 | ||
![]() |
a49f77135a | ||
![]() |
1eaf6e2db7 | ||
![]() |
b2683fdb11 | ||
![]() |
53cfd2dd9b | ||
![]() |
ec2327fddd | ||
![]() |
18f4064003 | ||
![]() |
990ad81419 | ||
![]() |
d7cdabe8e2 | ||
![]() |
269bb008fc | ||
![]() |
a987f8e67d | ||
![]() |
0aa40a9c21 | ||
![]() |
629b51ebf1 | ||
![]() |
39dbc65104 | ||
![]() |
0700d14065 | ||
![]() |
53e1764a8a | ||
![]() |
fda6e7f8de | ||
![]() |
6f994715d6 | ||
![]() |
8dad534464 | ||
![]() |
335a253323 | ||
![]() |
09483f422e | ||
![]() |
4692f496da | ||
![]() |
26b07fbdff | ||
![]() |
656549dd44 | ||
![]() |
ff3e7d4025 | ||
![]() |
f939adbedb | ||
![]() |
ac9a52886d | ||
![]() |
273aeeee73 | ||
![]() |
33c91398bf | ||
![]() |
087ce15ccd | ||
![]() |
92703939ee | ||
![]() |
d6ef0c47a5 | ||
![]() |
fd1eb7559b | ||
![]() |
c562a491ca | ||
![]() |
964e7c303c | ||
![]() |
1251684440 | ||
![]() |
2ecd1fac63 | ||
![]() |
46302a25d2 | ||
![]() |
d5638cb241 | ||
![]() |
e9f35e7b15 | ||
![]() |
fab5db0ec8 | ||
![]() |
4c8d3a70ea | ||
![]() |
c10ca74b5b | ||
![]() |
8d97b78da7 | ||
![]() |
d509e32c6f | ||
![]() |
61585251f5 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -2,3 +2,9 @@ HEAD
|
|||||||
src
|
src
|
||||||
v*
|
v*
|
||||||
alias
|
alias
|
||||||
|
|
||||||
|
# For testing
|
||||||
|
bak
|
||||||
|
.urchin.log
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2010-2013 Tim Caswell
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
135
README.markdown
135
README.markdown
@@ -4,38 +4,155 @@
|
|||||||
|
|
||||||
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.
|
||||||
|
|
||||||
To install create a folder somewhere in your filesystem with the "`nvm.sh`" file inside it. I put mine in a folder called "`.nvm`".
|
### Install script
|
||||||
|
|
||||||
|
To install you could use the [install script](https://github.com/creationix/nvm/blob/master/install.sh) (requires Git) using cURL:
|
||||||
|
|
||||||
|
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
|
||||||
|
|
||||||
|
or Wget:
|
||||||
|
|
||||||
|
wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
|
||||||
|
|
||||||
|
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile` or `~/.profile`).</sub>
|
||||||
|
|
||||||
|
|
||||||
|
### Manual install
|
||||||
|
|
||||||
|
For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in a folder called `nvm`.
|
||||||
|
|
||||||
Or if you have `git` installed, then just clone it:
|
Or if you have `git` installed, then just clone it:
|
||||||
|
|
||||||
git clone git://github.com/creationix/nvm.git ~/.nvm
|
git clone https://github.com/creationix/nvm.git ~/.nvm
|
||||||
|
|
||||||
To activate nvm, you need to source it from your bash shell
|
To activate nvm, you need to source it from your bash shell
|
||||||
|
|
||||||
. ~/.nvm/nvm.sh
|
source ~/.nvm/nvm.sh
|
||||||
|
|
||||||
I always add this line to my ~/.bashrc or ~/.profile file to have it automatically sources upon login.
|
I always add this line to my `~/.bashrc` or `~/.profile` file to have it automatically sourced upon login.
|
||||||
Often I also put in a line to use a specific version of node.
|
Often I also put in a line to use a specific version of node.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To download, compile, and install the v0.4.1 release of node, do this:
|
To download, compile, and install the latest v0.10.x release of node, do this:
|
||||||
|
|
||||||
nvm install v0.4.1
|
nvm install 0.10
|
||||||
|
|
||||||
And then in any new shell just use the installed version:
|
And then in any new shell just use the installed version:
|
||||||
|
|
||||||
nvm use v0.4.1
|
nvm use 0.10
|
||||||
|
|
||||||
If you want to see what versions are available:
|
You can create an `.nvmrc` file containing version number in the project root folder; run the following command to switch versions:
|
||||||
|
|
||||||
|
nvm use
|
||||||
|
|
||||||
|
Or you can just run it:
|
||||||
|
|
||||||
|
nvm run 0.10
|
||||||
|
|
||||||
|
If you want to see what versions are installed:
|
||||||
|
|
||||||
nvm ls
|
nvm ls
|
||||||
|
|
||||||
|
If you want to see what versions are available to install:
|
||||||
|
|
||||||
|
nvm ls-remote
|
||||||
|
|
||||||
To restore your PATH, you can deactivate it.
|
To restore your PATH, you can deactivate it.
|
||||||
|
|
||||||
nvm deactivate
|
nvm deactivate
|
||||||
|
|
||||||
To set a default Node version to be used in any new shell, use the alias 'default':
|
To set a default Node version to be used in any new shell, use the alias 'default':
|
||||||
|
|
||||||
nvm alias default v0.4.1
|
nvm alias default 0.10
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
nvm is released under the MIT license.
|
||||||
|
|
||||||
|
|
||||||
|
Copyright (C) 2010-2013 Tim Caswell
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
## Running tests
|
||||||
|
Tests are written in [Urchin](https://github.com/scraperwiki/urchin). Install Urchin like so.
|
||||||
|
|
||||||
|
wget -O /usr/local/bin https://raw.github.com/scraperwiki/urchin/0c6837cfbdd0963903bf0463b05160c2aecc22ef/urchin
|
||||||
|
chmod +x /usr/local/bin/urchin
|
||||||
|
|
||||||
|
(Or put it some other place in your PATH.)
|
||||||
|
|
||||||
|
There are slow tests and fast tests. The slow tests do things like install node
|
||||||
|
and check that the right versions are used. The fast tests fake this to test
|
||||||
|
things like aliases and uninstalling. From the root of the nvm git repository,
|
||||||
|
run the fast tests like this.
|
||||||
|
|
||||||
|
urchin test/fast
|
||||||
|
|
||||||
|
Run the slow tests like this.
|
||||||
|
|
||||||
|
urchin test/slow
|
||||||
|
|
||||||
|
Run all of the tests like this
|
||||||
|
|
||||||
|
urchin test
|
||||||
|
|
||||||
|
Nota bene: Avoid running nvm while the tests are running.
|
||||||
|
|
||||||
|
## Bash completion
|
||||||
|
|
||||||
|
To activate, you need to source `bash_completion`:
|
||||||
|
|
||||||
|
[[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion
|
||||||
|
|
||||||
|
Put the above sourcing line just below the sourcing line for NVM in your profile (`.bashrc`, `.bash_profile`).
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
nvm
|
||||||
|
|
||||||
|
$ nvm [tab][tab]
|
||||||
|
alias copy-packages help list run uninstall version
|
||||||
|
clear-cache deactivate install ls unalias use
|
||||||
|
|
||||||
|
nvm alias
|
||||||
|
|
||||||
|
$ nvm alias [tab][tab]
|
||||||
|
default
|
||||||
|
|
||||||
|
$ nvm alias my_alias [tab][tab]
|
||||||
|
v0.4.11 v0.4.12 v0.6.14
|
||||||
|
|
||||||
|
nvm use
|
||||||
|
|
||||||
|
$ nvm use [tab][tab]
|
||||||
|
my_alias default v0.4.11 v0.4.12 v0.6.14
|
||||||
|
|
||||||
|
nvm uninstall
|
||||||
|
|
||||||
|
$ nvm uninstall [tab][tab]
|
||||||
|
my_alias default v0.4.11 v0.4.12 v0.6.14
|
||||||
|
|
||||||
|
## Problems
|
||||||
|
|
||||||
|
If you try to install a node version and the installation fails, be sure to delete the node downloads from src (~/.nvm/src/) or you might get an error when trying to reinstall them again or you might get an error like the following:
|
||||||
|
|
||||||
|
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
|
||||||
|
|
||||||
|
Where's my 'sudo node'? Checkout this link:
|
||||||
|
|
||||||
|
https://github.com/creationix/nvm/issues/43
|
||||||
|
|
||||||
|
on Arch Linux and other systems using python3 by default, before running *install* you need to
|
||||||
|
|
||||||
|
export PYTHON=python2
|
||||||
|
|
||||||
|
After the v0.8.6 release of node, nvm tries to install from binary packages. But in some systems, the official binary packages don't work due to incompatibility of shared libs. In such cases, use `-s` option to force install from source:
|
||||||
|
|
||||||
|
nvm install -s 0.8.6
|
||||||
|
|
||||||
|
89
bash_completion
Normal file
89
bash_completion
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# bash completion for Node Version Manager (NVM)
|
||||||
|
|
||||||
|
__nvm_generate_completion()
|
||||||
|
{
|
||||||
|
declare current_word
|
||||||
|
current_word="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
COMPREPLY=($(compgen -W "$1" -- "$current_word"))
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_commands ()
|
||||||
|
{
|
||||||
|
declare current_word
|
||||||
|
declare command
|
||||||
|
|
||||||
|
current_word="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
|
||||||
|
COMMANDS='\
|
||||||
|
help install uninstall use run\
|
||||||
|
ls ls-remote list list-remote deactivate\
|
||||||
|
alias unalias copy-packages clear-cache version'
|
||||||
|
|
||||||
|
if [ ${#COMP_WORDS[@]} == 4 ]; then
|
||||||
|
|
||||||
|
command="${COMP_WORDS[COMP_CWORD-2]}"
|
||||||
|
case "${command}" in
|
||||||
|
alias) __nvm_installed_nodes ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
case "${current_word}" in
|
||||||
|
-*) __nvm_options ;;
|
||||||
|
*) __nvm_generate_completion "$COMMANDS" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_options ()
|
||||||
|
{
|
||||||
|
OPTIONS=''
|
||||||
|
__nvm_generate_completion "$OPTIONS"
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_installed_nodes ()
|
||||||
|
{
|
||||||
|
__nvm_generate_completion "$(nvm_ls) $(__nvm_aliases)"
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_aliases ()
|
||||||
|
{
|
||||||
|
declare aliases
|
||||||
|
aliases=""
|
||||||
|
if [ -d $NVM_DIR/alias ]; then
|
||||||
|
aliases="`cd $NVM_DIR/alias && ls`"
|
||||||
|
fi
|
||||||
|
echo "${aliases}"
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm_alias ()
|
||||||
|
{
|
||||||
|
__nvm_generate_completion "$(__nvm_aliases)"
|
||||||
|
}
|
||||||
|
|
||||||
|
__nvm ()
|
||||||
|
{
|
||||||
|
declare previous_word
|
||||||
|
previous_word="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
case "$previous_word" in
|
||||||
|
use|run|ls|list|uninstall) __nvm_installed_nodes ;;
|
||||||
|
alias|unalias) __nvm_alias ;;
|
||||||
|
*) __nvm_commands ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# complete is a bash builtin, but recent versions of ZSH come with a function
|
||||||
|
# called bashcompinit that will create a complete in ZSH. If the user is in
|
||||||
|
# ZSH, load and run bashcompinit before calling the complete function.
|
||||||
|
if [[ -n ${ZSH_VERSION-} ]]; then
|
||||||
|
autoload -U +X bashcompinit && bashcompinit
|
||||||
|
fi
|
||||||
|
|
||||||
|
complete -o default -o nospace -F __nvm nvm
|
59
install-gitless.sh
Executable file
59
install-gitless.sh
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function fatalExit (){
|
||||||
|
echo "$@" && exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
# an alternative URL that could be used: https://github.com/creationix/nvm/tarball/master
|
||||||
|
if [ "$NVM_SOURCE" == "" ]; then
|
||||||
|
NVM_SOURCE="https://raw.github.com/creationix/nvm/master/nvm.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$NVM_DIR" == "" ]; then
|
||||||
|
NVM_DIR="$HOME/.nvm"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Downloading to $NVM_DIR
|
||||||
|
mkdir -p "$NVM_DIR"
|
||||||
|
pushd "$NVM_DIR" > /dev/null
|
||||||
|
echo -ne "=> Downloading... "
|
||||||
|
curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed";
|
||||||
|
echo "Downloaded"
|
||||||
|
popd > /dev/null
|
||||||
|
|
||||||
|
# Detect profile file, .bash_profile has precedence over .profile
|
||||||
|
if [ ! -z "$1" ]; then
|
||||||
|
PROFILE="$1"
|
||||||
|
else
|
||||||
|
if [ -f "$HOME/.bash_profile" ]; then
|
||||||
|
PROFILE="$HOME/.bash_profile"
|
||||||
|
elif [ -f "$HOME/.profile" ]; then
|
||||||
|
PROFILE="$HOME/.profile"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
SOURCE_STR="[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" # This loads NVM"
|
||||||
|
|
||||||
|
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
|
||||||
|
if [ -z $PROFILE ]; then
|
||||||
|
echo "=> Profile not found"
|
||||||
|
else
|
||||||
|
echo "=> Profile $PROFILE not found"
|
||||||
|
fi
|
||||||
|
echo "=> Append the following line to the correct file yourself"
|
||||||
|
echo
|
||||||
|
echo "\t$SOURCE_STR"
|
||||||
|
echo
|
||||||
|
echo "=> Close and reopen your terminal to start using NVM"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep -qc 'nvm.sh' $PROFILE; then
|
||||||
|
echo "=> Appending source string to $PROFILE"
|
||||||
|
echo "" >> "$PROFILE"
|
||||||
|
echo $SOURCE_STR >> "$PROFILE"
|
||||||
|
else
|
||||||
|
echo "=> Source string already in $PROFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=> Close and reopen your terminal to start using NVM"
|
73
install.sh
73
install.sh
@@ -1,22 +1,65 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
dir=$npm_config_root/.npm/$npm_package_name/$npm_package_version/package
|
NVM_DIR="$HOME/.nvm"
|
||||||
|
|
||||||
# add lines to the bashrc.
|
if ! hash git 2>/dev/null; then
|
||||||
has=$(cat ~/.bashrc | egrep "^# ADDED BY npm FOR NVM$" || true)
|
echo >&2 "You need to install git - visit http://git-scm.com/downloads"
|
||||||
if [ "x$has" != "x" ]; then
|
echo >&2 "or, use install-gitless.sh instead."
|
||||||
exit 0
|
exit 1
|
||||||
fi
|
fi
|
||||||
cat <<NVM_CODE >>~/.bashrc
|
|
||||||
# ADDED BY npm FOR NVM
|
|
||||||
. $dir/nvm.sh
|
|
||||||
# END ADDED BY npm FOR NVM
|
|
||||||
NVM_CODE
|
|
||||||
|
|
||||||
cat <<NVM_HOWTO
|
if [ -d "$NVM_DIR" ]; then
|
||||||
|
echo "=> NVM is already installed in $NVM_DIR, trying to update"
|
||||||
|
echo -ne "\r=> "
|
||||||
|
cd $NVM_DIR && git pull
|
||||||
|
else
|
||||||
|
# Cloning to $NVM_DIR
|
||||||
|
git clone https://github.com/creationix/nvm.git $NVM_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
To use nvm, source your .bashrc file like this:
|
echo
|
||||||
. ~/.bashrc
|
|
||||||
or log out and back into your terminal.
|
|
||||||
|
|
||||||
NVM_HOWTO
|
# Detect profile file, .bash_profile has precedence over .profile
|
||||||
|
if [ ! -z "$1" ]; then
|
||||||
|
PROFILE="$1"
|
||||||
|
else
|
||||||
|
if [ -f "$HOME/.bash_profile" ]; then
|
||||||
|
PROFILE="$HOME/.bash_profile"
|
||||||
|
elif [ -f "$HOME/.zshrc" ]; then
|
||||||
|
PROFILE="$HOME/.zshrc"
|
||||||
|
elif [ -f "$HOME/.profile" ]; then
|
||||||
|
PROFILE="$HOME/.profile"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
SOURCE_STR="[ -s \$HOME/.nvm/nvm.sh ] && . \$HOME/.nvm/nvm.sh # This loads NVM"
|
||||||
|
|
||||||
|
if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then
|
||||||
|
if [ -z $PROFILE ]; then
|
||||||
|
echo "=> Profile not found. Tried $HOME/.bash_profile and $HOME/.profile"
|
||||||
|
else
|
||||||
|
echo "=> Profile $PROFILE not found"
|
||||||
|
fi
|
||||||
|
echo "=> Run this script again after running the following:"
|
||||||
|
echo
|
||||||
|
echo "\ttouch $HOME/.profile"
|
||||||
|
echo
|
||||||
|
echo "-- OR --"
|
||||||
|
echo
|
||||||
|
echo "=> Append the following line to the correct file yourself"
|
||||||
|
echo
|
||||||
|
echo "\t$SOURCE_STR"
|
||||||
|
echo
|
||||||
|
echo "=> Close and reopen your terminal afterwards to start using NVM"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep -qc 'nvm.sh' $PROFILE; then
|
||||||
|
echo "=> Appending source string to $PROFILE"
|
||||||
|
echo "" >> "$PROFILE"
|
||||||
|
echo $SOURCE_STR >> "$PROFILE"
|
||||||
|
else
|
||||||
|
echo "=> Source string already in $PROFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=> Close and reopen your terminal to start using NVM"
|
||||||
|
457
nvm.sh
Normal file → Executable file
457
nvm.sh
Normal file → Executable file
@@ -1,3 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
# Node Version Manager
|
# Node Version Manager
|
||||||
# Implemented as a bash function
|
# Implemented as a bash function
|
||||||
# To use source this file from your bash profile
|
# To use source this file from your bash profile
|
||||||
@@ -5,75 +7,163 @@
|
|||||||
# Implemented by Tim Caswell <tim@creationix.com>
|
# Implemented by Tim Caswell <tim@creationix.com>
|
||||||
# with much bash help from Matthew Ranney
|
# with much bash help from Matthew Ranney
|
||||||
|
|
||||||
|
# Make zsh glob matching behave same as bash
|
||||||
|
# This fixes the "zsh: no matches found" errors
|
||||||
|
if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then
|
||||||
|
unsetopt nomatch 2>/dev/null
|
||||||
|
NVM_CD_FLAGS="-q"
|
||||||
|
fi
|
||||||
|
|
||||||
# Auto detect the NVM_DIR
|
# Auto detect the NVM_DIR
|
||||||
if [ ! -d "$NVM_DIR" ]; then
|
if [ ! -d "$NVM_DIR" ]; then
|
||||||
export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}); pwd)
|
export NVM_DIR=$(cd $NVM_CD_FLAGS $(dirname ${BASH_SOURCE[0]:-$0}) > /dev/null && pwd)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Emulate curl with wget, if necessary
|
nvm_set_nullglob() {
|
||||||
if [ ! `which curl` ]; then
|
if type setopt > /dev/null 2>&1; then
|
||||||
if [ `which wget` ]; then
|
# Zsh
|
||||||
curl() {
|
setopt NULL_GLOB
|
||||||
ARGS="$* "
|
else
|
||||||
ARGS=${ARGS/-s /-q }
|
# Bash
|
||||||
ARGS=${ARGS/-\# /}
|
shopt -s nullglob
|
||||||
ARGS=${ARGS/-C - /-c }
|
fi
|
||||||
ARGS=${ARGS/-o /-O }
|
}
|
||||||
|
|
||||||
wget $ARGS
|
# Obtain nvm version from rc file
|
||||||
}
|
rc_nvm_version() {
|
||||||
else
|
if [ -e .nvmrc ]; then
|
||||||
NOCURL='nocurl'
|
RC_VERSION=`cat .nvmrc | head -n 1`
|
||||||
curl() { echo 'Need curl or wget to proceed.' >&2; }
|
echo "Found .nvmrc files with version <$RC_VERSION>"
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
# Expand a version using the version cache
|
# Expand a version using the version cache
|
||||||
nvm_version()
|
nvm_version() {
|
||||||
{
|
local PATTERN=$1
|
||||||
PATTERN=$1
|
# The default version is the current one
|
||||||
VERSION=''
|
if [ ! "$PATTERN" ]; then
|
||||||
|
PATTERN='current'
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION=`nvm_ls $PATTERN | tail -n1`
|
||||||
|
echo "$VERSION"
|
||||||
|
|
||||||
|
if [ "$VERSION" = 'N/A' ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_remote_version() {
|
||||||
|
local PATTERN=$1
|
||||||
|
VERSION=`nvm_ls_remote $PATTERN | tail -n1`
|
||||||
|
echo "$VERSION"
|
||||||
|
|
||||||
|
if [ "$VERSION" = 'N/A' ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_ls() {
|
||||||
|
local PATTERN=$1
|
||||||
|
local VERSIONS=''
|
||||||
|
if [ "$PATTERN" = 'current' ]; then
|
||||||
|
echo `node -v 2>/dev/null`
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
|
if [ -f "$NVM_DIR/alias/$PATTERN" ]; then
|
||||||
nvm_version `cat $NVM_DIR/alias/$PATTERN`
|
nvm_version `cat $NVM_DIR/alias/$PATTERN`
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# If it looks like an explicit version, don't do anything funny
|
# If it looks like an explicit version, don't do anything funny
|
||||||
if [[ "$PATTERN" == v*.*.* ]]; then
|
if [[ "$PATTERN" == v?*.?*.?* ]]; then
|
||||||
VERSION="$PATTERN"
|
VERSIONS="$PATTERN"
|
||||||
|
else
|
||||||
|
VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "v$PATTERN*" -exec basename '{}' ';' \
|
||||||
|
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
||||||
fi
|
fi
|
||||||
# The default version is the current one
|
if [ ! "$VERSIONS" ]; then
|
||||||
if [ ! "$PATTERN" -o "$PATTERN" = 'current' ]; then
|
echo "N/A"
|
||||||
VERSION=`node -v 2>/dev/null`
|
|
||||||
fi
|
|
||||||
if [ "$PATTERN" = 'stable' ]; then
|
|
||||||
PATTERN='*.*[02468].'
|
|
||||||
fi
|
|
||||||
if [ "$PATTERN" = 'latest' ]; then
|
|
||||||
PATTERN='*.*.'
|
|
||||||
fi
|
|
||||||
if [ "$PATTERN" = 'all' ]; then
|
|
||||||
(cd $NVM_DIR; ls -dG v* 2>/dev/null || echo "N/A")
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ ! "$VERSION" ]; then
|
echo "$VERSIONS"
|
||||||
VERSION=`(cd $NVM_DIR; ls -d v${PATTERN}* 2>/dev/null) | sort -t. -k 2,1n -k 2,2n -k 3,3n | tail -n1`
|
return
|
||||||
fi
|
}
|
||||||
if [ ! "$VERSION" ]; then
|
|
||||||
echo "N/A"
|
nvm_ls_remote() {
|
||||||
return 13
|
local PATTERN=$1
|
||||||
elif [ -e "$NVM_DIR/$VERSION" ]; then
|
local VERSIONS
|
||||||
(cd $NVM_DIR; ls -dG "$VERSION")
|
if [ "$PATTERN" ]; then
|
||||||
|
if echo "${PATTERN}" | \grep -v '^v' ; then
|
||||||
|
PATTERN=v$PATTERN
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "$VERSION"
|
PATTERN=".*"
|
||||||
|
fi
|
||||||
|
VERSIONS=`curl -s http://nodejs.org/dist/ \
|
||||||
|
| \egrep -o 'v[0-9]+\.[0-9]+\.[0-9]+' \
|
||||||
|
| \grep -w "${PATTERN}" \
|
||||||
|
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
|
||||||
|
if [ ! "$VERSIONS" ]; then
|
||||||
|
echo "N/A"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "$VERSIONS"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm_checksum() {
|
||||||
|
if [ "$1" = "$2" ]; then
|
||||||
|
return
|
||||||
|
elif [ -z $2 ]; then
|
||||||
|
echo 'Checksums empty' #missing in raspberry pi binary
|
||||||
|
return
|
||||||
|
else
|
||||||
|
echo 'Checksums do not match.'
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm()
|
|
||||||
{
|
print_versions() {
|
||||||
|
local OUTPUT=''
|
||||||
|
local PADDED_VERSION=''
|
||||||
|
for VERSION in $1; do
|
||||||
|
PADDED_VERSION=`printf '%10s' $VERSION`
|
||||||
|
if [[ -d "$NVM_DIR/$VERSION" ]]; then
|
||||||
|
PADDED_VERSION="\033[0;34m$PADDED_VERSION\033[0m"
|
||||||
|
fi
|
||||||
|
OUTPUT="$OUTPUT\n$PADDED_VERSION"
|
||||||
|
done
|
||||||
|
echo -e "$OUTPUT"
|
||||||
|
}
|
||||||
|
|
||||||
|
nvm() {
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
nvm help
|
nvm help
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Try to figure out the os and arch for binary fetching
|
||||||
|
local uname="$(uname -a)"
|
||||||
|
local os=
|
||||||
|
local arch="$(uname -m)"
|
||||||
|
case "$uname" in
|
||||||
|
Linux\ *) os=linux ;;
|
||||||
|
Darwin\ *) os=darwin ;;
|
||||||
|
SunOS\ *) os=sunos ;;
|
||||||
|
FreeBSD\ *) os=freebsd ;;
|
||||||
|
esac
|
||||||
|
case "$uname" in
|
||||||
|
*x86_64*) arch=x64 ;;
|
||||||
|
*i*86*) arch=x86 ;;
|
||||||
|
*armv6l*) arch=arm-pi ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# initialize local variables
|
||||||
|
local VERSION
|
||||||
|
local ADDITIONAL_PARAMETERS
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"help" )
|
"help" )
|
||||||
echo
|
echo
|
||||||
@@ -81,54 +171,193 @@ nvm()
|
|||||||
echo
|
echo
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " nvm help Show this message"
|
echo " nvm help Show this message"
|
||||||
echo " nvm install <version> Download and install a <version>"
|
echo " nvm install [-s] <version> Download and install a <version>"
|
||||||
|
echo " nvm uninstall <version> Uninstall a version"
|
||||||
echo " nvm use <version> Modify PATH to use <version>"
|
echo " nvm use <version> Modify PATH to use <version>"
|
||||||
echo " nvm ls List versions (installed versions are blue)"
|
echo " nvm run <version> [<args>] Run <version> with <args> as arguments"
|
||||||
|
echo " nvm ls List installed versions"
|
||||||
echo " nvm ls <version> List versions matching a given description"
|
echo " nvm ls <version> List versions matching a given description"
|
||||||
|
echo " nvm ls-remote List remote versions available for install"
|
||||||
echo " nvm deactivate Undo effects of NVM on current shell"
|
echo " nvm deactivate Undo effects of NVM on current shell"
|
||||||
echo " nvm sync Update the local cache of available versions"
|
|
||||||
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
|
echo " nvm alias [<pattern>] Show all aliases beginning with <pattern>"
|
||||||
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
|
echo " nvm alias <name> <version> Set an alias named <name> pointing to <version>"
|
||||||
|
echo " nvm unalias <name> Deletes the alias named <name>"
|
||||||
|
echo " nvm copy-packages <version> Install global NPM packages contained in <version> to current version"
|
||||||
echo
|
echo
|
||||||
echo "Example:"
|
echo "Example:"
|
||||||
echo " nvm install v0.4.0 Install a specific version number"
|
echo " nvm install v0.4.12 Install a specific version number"
|
||||||
echo " nvm use stable Use the stable release"
|
|
||||||
echo " nvm install latest Install the latest, possibly unstable version"
|
|
||||||
echo " nvm use 0.2 Use the latest available 0.2.x release"
|
echo " nvm use 0.2 Use the latest available 0.2.x release"
|
||||||
echo " nvm alias default v0.4.0 Set v0.4.0 as the default"
|
echo " nvm run 0.4.12 myApp.js Run myApp.js using node v0.4.12"
|
||||||
|
echo " nvm alias default 0.4 Auto use the latest installed v0.4.x version"
|
||||||
echo
|
echo
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"install" )
|
"install" )
|
||||||
if [ $# -ne 2 ]; then
|
# initialize local variables
|
||||||
|
local binavail
|
||||||
|
local t
|
||||||
|
local url
|
||||||
|
local sum
|
||||||
|
local tarball
|
||||||
|
local shasum='shasum'
|
||||||
|
local nobinary
|
||||||
|
|
||||||
|
if [ ! `\which curl` ]; then
|
||||||
|
echo 'NVM Needs curl to proceed.' >&2;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! `\which shasum` ]; then
|
||||||
|
shasum='sha1sum'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
nvm help
|
nvm help
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
[ "$NOCURL" ] && curl && return
|
|
||||||
VERSION=`nvm_version $2`
|
shift
|
||||||
|
|
||||||
|
nobinary=0
|
||||||
|
if [ "$1" = "-s" ]; then
|
||||||
|
nobinary=1
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$os" = "freebsd" ]; then
|
||||||
|
nobinary=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION=`nvm_remote_version $1`
|
||||||
|
ADDITIONAL_PARAMETERS=''
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
while [ $# -ne 0 ]
|
||||||
|
do
|
||||||
|
ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
[ -d "$NVM_DIR/$VERSION" ] && echo "$VERSION is already installed." && return
|
||||||
|
|
||||||
|
# skip binary install if no binary option specified.
|
||||||
|
if [ $nobinary -ne 1 ]; then
|
||||||
|
# shortcut - try the binary if possible.
|
||||||
|
if [ -n "$os" ]; then
|
||||||
|
binavail=
|
||||||
|
# binaries started with node 0.8.6
|
||||||
|
case "$VERSION" in
|
||||||
|
v0.8.[012345]) binavail=0 ;;
|
||||||
|
v0.[1234567].*) binavail=0 ;;
|
||||||
|
*) binavail=1 ;;
|
||||||
|
esac
|
||||||
|
if [ $binavail -eq 1 ]; then
|
||||||
|
t="$VERSION-$os-$arch"
|
||||||
|
url="http://nodejs.org/dist/$VERSION/node-${t}.tar.gz"
|
||||||
|
sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | \grep node-${t}.tar.gz | awk '{print $1}'`
|
||||||
|
local tmpdir="$NVM_DIR/bin/node-${t}"
|
||||||
|
local tmptarball="$tmpdir/node-${t}.tar.gz"
|
||||||
|
if (
|
||||||
|
mkdir -p "$tmpdir" && \
|
||||||
|
curl -L -C - --progress-bar $url -o "$tmptarball" && \
|
||||||
|
nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum && \
|
||||||
|
tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||||
|
rm -f "$tmptarball" && \
|
||||||
|
mv "$tmpdir" "$NVM_DIR/$VERSION"
|
||||||
|
)
|
||||||
|
then
|
||||||
|
nvm use $VERSION
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
echo "Binary download failed, trying source." >&2
|
||||||
|
rm -rf "$tmptarball" "$tmpdir"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Additional options while compiling: $ADDITIONAL_PARAMETERS"
|
||||||
|
|
||||||
|
tarball=''
|
||||||
|
sum=''
|
||||||
|
make='make'
|
||||||
|
if [ "$os" = "freebsd" ]; then
|
||||||
|
make='gmake'
|
||||||
|
fi
|
||||||
|
local tmpdir="$NVM_DIR/src"
|
||||||
|
local tmptarball="$tmpdir/node-$VERSION.tar.gz"
|
||||||
|
if [ "`curl -Is "http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
|
||||||
|
tarball="http://nodejs.org/dist/$VERSION/node-$VERSION.tar.gz"
|
||||||
|
sum=`curl -s http://nodejs.org/dist/$VERSION/SHASUMS.txt | \grep node-$VERSION.tar.gz | awk '{print $1}'`
|
||||||
|
elif [ "`curl -Is "http://nodejs.org/dist/node-$VERSION.tar.gz" | \grep '200 OK'`" != '' ]; then
|
||||||
|
tarball="http://nodejs.org/dist/node-$VERSION.tar.gz"
|
||||||
|
fi
|
||||||
if (
|
if (
|
||||||
mkdir -p "$NVM_DIR/src" && \
|
[ ! -z $tarball ] && \
|
||||||
cd "$NVM_DIR/src" && \
|
mkdir -p "$tmpdir" && \
|
||||||
curl -C - -# "http://nodejs.org/dist/node-$VERSION.tar.gz" -o "node-$VERSION.tar.gz" && \
|
curl -L --progress-bar $tarball -o "$tmptarball" && \
|
||||||
tar -xzf "node-$VERSION.tar.gz" && \
|
if [ "$sum" = "" ]; then : ; else nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum; fi && \
|
||||||
cd "node-$VERSION" && \
|
tar -xzf "$tmptarball" -C "$tmpdir" && \
|
||||||
./configure --prefix="$NVM_DIR/$VERSION" && \
|
cd "$tmpdir/node-$VERSION" && \
|
||||||
make && \
|
./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \
|
||||||
|
$make && \
|
||||||
rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \
|
rm -f "$NVM_DIR/$VERSION" 2>/dev/null && \
|
||||||
make install
|
$make install
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
nvm use $VERSION
|
nvm use $VERSION
|
||||||
if ! which npm ; then
|
if ! which npm ; then
|
||||||
echo "Installing npm..."
|
echo "Installing npm..."
|
||||||
curl http://npmjs.org/install.sh | sh
|
if [[ "`expr match $VERSION '\(^v0\.1\.\)'`" != '' ]]; then
|
||||||
|
echo "npm requires node v0.2.3 or higher"
|
||||||
|
elif [[ "`expr match $VERSION '\(^v0\.2\.\)'`" != '' ]]; then
|
||||||
|
if [[ "`expr match $VERSION '\(^v0\.2\.[0-2]$\)'`" != '' ]]; then
|
||||||
|
echo "npm requires node v0.2.3 or higher"
|
||||||
|
else
|
||||||
|
curl https://npmjs.org/install.sh | clean=yes npm_install=0.2.19 sh
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
curl https://npmjs.org/install.sh | clean=yes sh
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "nvm: install $VERSION failed!"
|
echo "nvm: install $VERSION failed!"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
"uninstall" )
|
||||||
|
[ $# -ne 2 ] && nvm help && return
|
||||||
|
if [[ $2 == `nvm_version` ]]; then
|
||||||
|
echo "nvm: Cannot uninstall currently-active node version, $2."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
VERSION=`nvm_version $2`
|
||||||
|
if [ ! -d $NVM_DIR/$VERSION ]; then
|
||||||
|
echo "$VERSION version is not installed..."
|
||||||
|
return;
|
||||||
|
fi
|
||||||
|
|
||||||
|
t="$VERSION-$os-$arch"
|
||||||
|
|
||||||
|
# Delete all files related to target version.
|
||||||
|
rm -rf "$NVM_DIR/src/node-$VERSION" \
|
||||||
|
"$NVM_DIR/src/node-$VERSION.tar.gz" \
|
||||||
|
"$NVM_DIR/bin/node-${t}" \
|
||||||
|
"$NVM_DIR/bin/node-${t}.tar.gz" \
|
||||||
|
"$NVM_DIR/$VERSION" 2>/dev/null
|
||||||
|
echo "Uninstalled node $VERSION"
|
||||||
|
|
||||||
|
# Rm any aliases that point to uninstalled version.
|
||||||
|
for A in `\grep -l $VERSION $NVM_DIR/alias/* 2>/dev/null`
|
||||||
|
do
|
||||||
|
nvm unalias `basename $A`
|
||||||
|
done
|
||||||
|
|
||||||
|
;;
|
||||||
"deactivate" )
|
"deactivate" )
|
||||||
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
|
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
|
||||||
export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/bin:}
|
export PATH=${PATH%$NVM_DIR/*/bin*}${PATH#*$NVM_DIR/*/bin:}
|
||||||
|
hash -r
|
||||||
echo "$NVM_DIR/*/bin removed from \$PATH"
|
echo "$NVM_DIR/*/bin removed from \$PATH"
|
||||||
else
|
else
|
||||||
echo "Could not find $NVM_DIR/*/bin in \$PATH"
|
echo "Could not find $NVM_DIR/*/bin in \$PATH"
|
||||||
@@ -141,14 +370,28 @@ nvm()
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"use" )
|
"use" )
|
||||||
if [ $# -ne 2 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
nvm help
|
nvm help
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
VERSION=`nvm_version $2`
|
if [ $# -eq 1 ]; then
|
||||||
if [ ! -d $NVM_DIR/$VERSION ]; then
|
rc_nvm_version
|
||||||
|
if [ ! -z $RC_VERSION ]; then
|
||||||
|
VERSION=`nvm_version $RC_VERSION`
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
VERSION=`nvm_version $2`
|
||||||
|
fi
|
||||||
|
if [ -z $VERSION ]; then
|
||||||
|
nvm help
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [ -z $VERSION ]; then
|
||||||
|
VERSION=`nvm_version $2`
|
||||||
|
fi
|
||||||
|
if [ ! -d "$NVM_DIR/$VERSION" ]; then
|
||||||
echo "$VERSION version is not installed yet"
|
echo "$VERSION version is not installed yet"
|
||||||
return;
|
return 1
|
||||||
fi
|
fi
|
||||||
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
|
if [[ $PATH == *$NVM_DIR/*/bin* ]]; then
|
||||||
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin}
|
PATH=${PATH%$NVM_DIR/*/bin*}$NVM_DIR/$VERSION/bin${PATH#*$NVM_DIR/*/bin}
|
||||||
@@ -161,35 +404,50 @@ nvm()
|
|||||||
MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH"
|
MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH"
|
||||||
fi
|
fi
|
||||||
export PATH
|
export PATH
|
||||||
|
hash -r
|
||||||
export MANPATH
|
export MANPATH
|
||||||
export NVM_PATH="$NVM_DIR/$VERSION/lib/node"
|
export NVM_PATH="$NVM_DIR/$VERSION/lib/node"
|
||||||
export NVM_BIN="$NVM_DIR/$VERSION/bin"
|
export NVM_BIN="$NVM_DIR/$VERSION/bin"
|
||||||
echo "Now using node $VERSION"
|
echo "Now using node $VERSION"
|
||||||
;;
|
;;
|
||||||
"ls" )
|
"run" )
|
||||||
if [ $# -ne 1 ]; then
|
# run given version of node
|
||||||
nvm_version $2
|
if [ $# -lt 2 ]; then
|
||||||
|
nvm help
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
nvm_version all
|
VERSION=`nvm_version $2`
|
||||||
for P in {stable,latest,current}; do
|
if [ ! -d $NVM_DIR/$VERSION ]; then
|
||||||
echo -ne "$P: \t"; nvm_version $P
|
echo "$VERSION version is not installed yet"
|
||||||
done
|
return;
|
||||||
nvm alias
|
fi
|
||||||
echo "# use 'nvm sync' to update from nodejs.org"
|
echo "Running node $VERSION"
|
||||||
|
$NVM_DIR/$VERSION/bin/node "${@:3}"
|
||||||
|
;;
|
||||||
|
"ls" | "list" )
|
||||||
|
print_versions "`nvm_ls $2`"
|
||||||
|
if [ $# -eq 1 ]; then
|
||||||
|
echo -ne "current: \t"; nvm_version current
|
||||||
|
nvm alias
|
||||||
|
fi
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
"ls-remote" | "list-remote" )
|
||||||
|
print_versions "`nvm_ls_remote $2`"
|
||||||
|
return
|
||||||
;;
|
;;
|
||||||
"alias" )
|
"alias" )
|
||||||
mkdir -p $NVM_DIR/alias
|
mkdir -p $NVM_DIR/alias
|
||||||
if [ $# -le 2 ]; then
|
if [ $# -le 2 ]; then
|
||||||
(cd $NVM_DIR/alias && for ALIAS in `ls $2* 2>/dev/null`; do
|
for ALIAS in $(nvm_set_nullglob; echo $NVM_DIR/alias/$2* ); do
|
||||||
DEST=`cat $ALIAS`
|
DEST=`cat $ALIAS`
|
||||||
VERSION=`nvm_version $DEST`
|
VERSION=`nvm_version $DEST`
|
||||||
if [ "$DEST" = "$VERSION" ]; then
|
if [ "$DEST" = "$VERSION" ]; then
|
||||||
echo "$ALIAS -> $DEST"
|
echo "$(basename $ALIAS) -> $DEST"
|
||||||
else
|
else
|
||||||
echo "$ALIAS -> $DEST (-> $VERSION)"
|
echo "$(basename $ALIAS) -> $DEST (-> $VERSION)"
|
||||||
fi
|
fi
|
||||||
done)
|
done
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ ! "$3" ]; then
|
if [ ! "$3" ]; then
|
||||||
@@ -205,32 +463,33 @@ nvm()
|
|||||||
echo $3 > "$NVM_DIR/alias/$2"
|
echo $3 > "$NVM_DIR/alias/$2"
|
||||||
if [ ! "$3" = "$VERSION" ]; then
|
if [ ! "$3" = "$VERSION" ]; then
|
||||||
echo "$2 -> $3 (-> $VERSION)"
|
echo "$2 -> $3 (-> $VERSION)"
|
||||||
echo "! WARNING: Moving target. Aliases to implicit versions may change without warning."
|
|
||||||
else
|
else
|
||||||
echo "$2 -> $3"
|
echo "$2 -> $3"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"sync" )
|
"unalias" )
|
||||||
[ "$NOCURL" ] && curl && return
|
mkdir -p $NVM_DIR/alias
|
||||||
LATEST=`nvm_version latest`
|
[ $# -ne 2 ] && nvm help && return
|
||||||
STABLE=`nvm_version stable`
|
[ ! -f $NVM_DIR/alias/$2 ] && echo "Alias $2 doesn't exist!" && return
|
||||||
(cd $NVM_DIR
|
rm -f $NVM_DIR/alias/$2
|
||||||
rm -f v* 2>/dev/null
|
echo "Deleted alias $2"
|
||||||
printf "# syncing with nodejs.org..."
|
;;
|
||||||
for VER in `curl -s http://nodejs.org/dist/ -o - | grep 'node-v.*\.tar\.gz' | sed -e 's/.*node-//' -e 's/\.tar\.gz.*//'`; do
|
"copy-packages" )
|
||||||
touch $VER
|
if [ $# -ne 2 ]; then
|
||||||
done
|
nvm help
|
||||||
echo " done."
|
return
|
||||||
)
|
fi
|
||||||
[ "$STABLE" = `nvm_version stable` ] || echo "NEW stable: `nvm_version stable`"
|
VERSION=`nvm_version $2`
|
||||||
[ "$LATEST" = `nvm_version latest` ] || echo "NEW latest: `nvm_version latest`"
|
ROOT=`nvm use $VERSION && npm -g root`
|
||||||
|
INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "`
|
||||||
|
npm install -g $INSTALLS
|
||||||
;;
|
;;
|
||||||
"clear-cache" )
|
"clear-cache" )
|
||||||
rm -f $NVM_DIR/v* 2>/dev/null
|
rm -f $NVM_DIR/v* 2>/dev/null
|
||||||
echo "Cache cleared."
|
echo "Cache cleared."
|
||||||
;;
|
;;
|
||||||
"version" )
|
"version" )
|
||||||
nvm_version $2
|
print_versions "`nvm_version $2`"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
nvm help
|
nvm help
|
||||||
@@ -238,4 +497,4 @@ nvm()
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm ls default >/dev/null 2>&1 && nvm use default >/dev/null
|
nvm ls default &>/dev/null && nvm use default >/dev/null || true
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
{ "name" : "nvm"
|
|
||||||
, "version" : "0.1.0"
|
|
||||||
, "author" : "Tim Caswell <tim@creationix.org>"
|
|
||||||
, "scripts" :
|
|
||||||
{ "install" : "./install.sh" , "uninstall" : "./uninstall.sh" }
|
|
||||||
}
|
|
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
[ $(nvm alias test1 | wc -l) = '2' ]
|
4
test/fast/Aliases/Running "nvm alias" should list all aliases.
Executable file
4
test/fast/Aliases/Running "nvm alias" should list all aliases.
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
[ $(nvm alias | wc -l) = '10' ]
|
6
test/fast/Aliases/setup_dir
Executable file
6
test/fast/Aliases/setup_dir
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
for i in $(seq 1 10)
|
||||||
|
do
|
||||||
|
echo v0.0.$i > ../../../alias/test$i
|
||||||
|
done
|
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.1.3
|
||||||
|
mkdir ../../../v0.2.3
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
# The result should contain only the appropriate version numbers.
|
||||||
|
nvm ls 0.2 | grep v0.2.3 &&
|
||||||
|
nvm ls 0.1 | grep -v v0.2.3
|
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.0.{1,3,9}
|
||||||
|
mkdir ../../../v0.3.{1,3,9}
|
||||||
|
|
||||||
|
# The result should contain the version numbers.
|
||||||
|
nvm ls | grep v0.0.1 &&
|
||||||
|
nvm ls | grep v0.0.3 &&
|
||||||
|
nvm ls | grep v0.0.9 &&
|
||||||
|
nvm ls | grep v0.3.1 &&
|
||||||
|
nvm ls | grep v0.3.3 &&
|
||||||
|
nvm ls | grep v0.3.9
|
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm alias test v0.1.2
|
||||||
|
[ $(cat ../../alias/test) = 'v0.1.2' ]
|
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir -p ../../v0.2.3
|
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
|
[[ $PATH != *v0.2.3/*/bin* ]] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm use v0.2.3 &&
|
||||||
|
[[ $PATH == *v0.2.3/*/bin* ]] || die "Failed to activate v0.2.3"
|
||||||
|
|
||||||
|
nvm deactivate &&
|
||||||
|
[[ $PATH != *v0.2.3/*/bin* ]] || die "Failed to deactivate v0.2.3"
|
6
test/fast/Running "nvm unalias" should remove the alias file.
Executable file
6
test/fast/Running "nvm unalias" should remove the alias file.
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo v0.1.2 > ../../alias/test
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm unalias test
|
||||||
|
! [ -e ../../alias/test ]
|
10
test/fast/Running "nvm uninstall" should remove the appropriate directory.
Executable file
10
test/fast/Running "nvm uninstall" should remove the appropriate directory.
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd ../..
|
||||||
|
mkdir v0.0.1
|
||||||
|
mkdir src/node-v0.0.1
|
||||||
|
|
||||||
|
. ./nvm.sh
|
||||||
|
nvm uninstall v0.0.1
|
||||||
|
|
||||||
|
[ ! -d 'v0.0.1' ] && [ ! -d 'src/node-v0.0.1' ]
|
4
test/fast/Sourcing nvm.sh should make the nvm command available.
Executable file
4
test/fast/Sourcing nvm.sh should make the nvm command available.
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm
|
12
test/fast/setup
Executable file
12
test/fast/setup
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Back up
|
||||||
|
|
||||||
|
type setopt >/dev/null 2>&1 && setopt NULL_GLOB
|
||||||
|
type shopt >/dev/null 2>&1 && shopt -s nullglob
|
||||||
|
rm -Rf v* src alias
|
||||||
|
mkdir src alias
|
||||||
|
)
|
12
test/fast/setup_dir
Executable file
12
test/fast/setup_dir
Executable file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Back up
|
||||||
|
|
||||||
|
type setopt >/dev/null 2>&1 && setopt NULL_GLOB
|
||||||
|
type shopt >/dev/null 2>&1 && shopt -s nullglob
|
||||||
|
mkdir -p bak
|
||||||
|
mv v* src alias bak || sleep 0s
|
||||||
|
)
|
10
test/fast/teardown
Executable file
10
test/fast/teardown
Executable file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Remove temporary files
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
type setopt >/dev/null 2>&1 && setopt NULL_GLOB
|
||||||
|
type shopt >/dev/null 2>&1 && shopt -s nullglob
|
||||||
|
rm -fR v* src alias
|
||||||
|
)
|
13
test/fast/teardown_dir
Executable file
13
test/fast/teardown_dir
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Restore
|
||||||
|
if [ -d bak ]
|
||||||
|
then
|
||||||
|
mv bak/* . || sleep 0s
|
||||||
|
rmdir bak
|
||||||
|
fi
|
||||||
|
mkdir -p src alias
|
||||||
|
)
|
14
test/slow/install
Executable file
14
test/slow/install
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../v0.6.14 ] && rm -R ../../v0.6.14
|
||||||
|
|
||||||
|
# Install
|
||||||
|
nvm install 0.6.14
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../v0.6.14 ]
|
||||||
|
nvm run v0.6.14 --version | grep v0.6.14
|
14
test/slow/install from binary
Executable file
14
test/slow/install from binary
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../v0.8.6 ] && rm -R ../../v0.8.6
|
||||||
|
|
||||||
|
# Install from binary
|
||||||
|
nvm install 0.8.6
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../v0.8.6 ]
|
||||||
|
nvm run v0.8.6 --version | grep v0.8.6
|
14
test/slow/install from source
Executable file
14
test/slow/install from source
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../v0.8.6 ] && rm -R ../../v0.8.6
|
||||||
|
|
||||||
|
# Install from source
|
||||||
|
nvm install -s 0.8.6
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../v0.8.6 ]
|
||||||
|
nvm run v0.8.6 --version | grep v0.8.6
|
23
uninstall.sh
23
uninstall.sh
@@ -1,23 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
|
|
||||||
has=$(cat ~/.bashrc | egrep "^# ADDED BY npm FOR NVM$" || true)
|
|
||||||
if [ "x$has" == "x" ]; then
|
|
||||||
echo "doesn't have it, exiting"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
tmp=~/.bashrc.tmp
|
|
||||||
cat ~/.bashrc | {
|
|
||||||
incode=0
|
|
||||||
while read line; do
|
|
||||||
if [ "$line" == "# ADDED BY npm FOR NVM" ]; then
|
|
||||||
incode=1
|
|
||||||
elif [ "$line" == "# END ADDED BY npm FOR NVM" ] \
|
|
||||||
&& [ $incode -eq 1 ]; then
|
|
||||||
incode=0
|
|
||||||
elif [ $incode -eq 0 ]; then
|
|
||||||
echo "$line" >> $tmp
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
mv $tmp ~/.bashrc
|
|
Reference in New Issue
Block a user