Compare commits

...

658 Commits

Author SHA1 Message Date
Jordan Harband
977563e97d
v0.40.3 2025-04-23 16:34:31 -07:00
Toni Viemerö
99352a64d2
[Fix] nvm_install_latest_npm: fix node version detection 2025-04-09 08:16:05 +03:00
Jordan Harband
ffec9fec72
v0.40.2
New Stuff
 - `install.sh`: add `$ZDOTDIR` to zsh search (#3458)

Fixes
 - `reinstall-packages`: do not reinstall corepack (#3544)
 - avoid bash-specific syntax (#3499)
 - `install-latest-npm`: npm v11 is out
 - `nvm_install_latest_npm`: avoid unbound variable (#3447)
 - give a more helpful message when `lts` alias is mistakenly used (#3441)
 - `nvm ls`, `nvm alias`, `nvm install`: error when an LTS name is invalid
 - `nvm_normalize_lts`: error when an LTS name is not lowercase (#3417)

Documentation
 - [readme] update link
 - [readme] fix `--no-use` example (#3479)
 - [readme] update copyright notice (#3507)
 - [readme] note zsh-nvm's AUTO_USE option (#2670)
 - [readme] add note about reloading zshrc after editing (#3052)
 - [readme] Update shell profile file install notes (#2241)
 - [readme] add docker tips (#2318)
 - [readme] remove `avn` from readme (#3469)
 - [readme] fnm -> nvm.fish (#2541)

Refactors
 - prefer `case` over if/else chains
 - combine `sed -e` invocations/arguments

Tests
 - `nvm exec`/`nvm run`: add `--silent` tests (#1259)
 - [actions] release test needs git tags
 - migrate `installation_iojs` test suite to GitHub Actions (#3476)
 - Migrate slow test suite from Travis CI (#3470)
 - temporarily skip this failing travis test to unblock progress
 - [actions] TOC: use latest LTS node
 - `install.sh`: clean up `nvm_detect_profile` tests
 - `nvm_detect_profile`: refactor (#3467)
 - run urchin tests on pull requests (#3466)
 - update mocks
 - ensure that unit tests use only mocked LTS names
 - [actions] use `node/install` instead of `node/run`

Meta
 - disable blank issues
 - update issue template
 - add DCO (#3456)
 - Rename .github/ISSUE_TEMPLATE.md to .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md (#3454)
2025-03-11 13:39:40 -07:00
Jordan Harband
df9ac58f8b
[Fix] reinstall-packages: do not reinstall corepack
Fixes #3544
2025-03-11 13:16:58 -07:00
Jordan Harband
8dbc22f0e9
[readme] update link 2025-03-11 12:46:19 -07:00
Jordan Harband
5c12680a62
[Dev Deps] update markdown-link-check 2025-03-11 12:43:42 -07:00
Jordan Harband
f0f8ed12f8
[Dev Deps] update semver 2025-02-25 18:39:49 -08:00
Jordan Harband
759f70f196
[Refactor] prefer case over if/else chains 2025-02-04 22:45:35 -08:00
Jordan Harband
06a9179309
[Refactor] combine sed -e invocations/arguments 2025-02-04 15:55:10 -08:00
Jordan Harband
74eb396099
[Dev Deps] update markdown-link-check 2025-02-04 12:37:59 -08:00
Atsushi Yamamoto
9f520c97db
[Tests] nvm exec/nvm run: add --silent tests
Co-authored-by: Atsushi Yamamoto <yamaatsushi927@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2016-10-11 23:43:10 -07:00
Jordan Harband
e5521cfd3c
[actions] release test needs git tags 2025-02-04 08:44:48 -08:00
Jérémy GAU
247ed8a186
[readme] fix --no-use example 2024-11-28 20:33:25 +01:00
Jessica Wagantall
14507f807f
[Tests] migrate installation_iojs test suite to GitHub Actions
Remove equivalent TravisCI entries

Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
2024-11-21 15:14:14 -08:00
Jessica Wagantall
6135555b40
[Tests] Migrate slow test suite from Travis CI
Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
2024-11-14 16:11:04 -08:00
Chris de Almeida
d90a7910db
[readme] update copyright notice 2025-01-10 14:41:50 -06:00
Andy Gimblett
8c30ac633b
[readme] note zsh-nvm's AUTO_USE option 2021-12-01 14:55:38 +00:00
Nicola Lanzoni
ecdc865a5a
[readme] add note about reloading zshrc after editing 2023-03-09 09:39:55 -03:00
Asad Akbar
9bcbbef4eb
[readme] Update shell profile file install notes
* Adds a note for how to fix the issue when the install script is not   updating the correct profile file.
2020-06-19 16:36:09 -07:00
Björn Holm
b77fcec399
[readme] add docker tips
- covers installation using BASH_ENV

Co-authored-by: Christopher Dieringer <cdaringe@users.noreply.github.com>
Co-authored-by: Björn Holm <blollle@gmail.com>
2022-11-14 00:16:13 +01:00
Andrew Chang-DeWitt
287d535f2c
[readme] remove avn from readme
`avn` is archived ([see repo](https://github.com/direnv/direnv)) and should probably no longer be recommended by nvm.

This also adds a solution using `direnv` and proposes a possible `.envrc` to use.
See [wbyoung/avn#109](https://github.com/wbyoung/avn/issues/109#issuecomment-1281865585) for more suggested `.envrc` files.
2024-11-13 14:41:39 -06:00
Kid
572c757f6d
[readme] fnm -> nvm.fish 2021-07-18 18:32:40 +08:00
Jordan Harband
1d39e35bd3
[Tests] temporarily skip this failing travis test to unblock progress 2025-02-03 10:50:19 -08:00
Jordan Harband
19f452ba0f
[Fix] avoid bash-specific syntax
Fixes #3499
2024-12-19 22:21:09 -08:00
Jordan Harband
b9b0ea8020
[Fix] install-latest-npm: npm v11 is out 2024-12-16 10:03:18 -08:00
Jordan Harband
dae1427f7e
[actions] TOC: use latest LTS node 2024-11-22 21:44:36 -10:00
Jordan Harband
0641363102
[Tests] install.sh: clean up nvm_detect_profile tests 2024-11-08 10:52:41 +00:00
Jordan Harband
9659af6c16
[Tests] nvm_detect_profile: refactor 2024-11-12 13:31:36 -08:00
menaechmi
abd02e5aae
[Fix] install.sh: fix failing install tests (#3458) 2024-11-12 11:57:02 -06:00
menaechmi
3de0b15810
[Tests] run urchin tests on pull requests 2024-11-12 12:58:53 -06:00
menaechmi
cd22c84026
[New] install.sh: add $ZDOTDIR to zsh search
Fixes #3128
2024-11-06 16:53:58 -06:00
Jordan Harband
d648a3b1ba
[meta] add DCO
imo this shouldn‘t be necessary, as it should be implied by the act of making a PR.

Following the example in https://github.com/expressjs/express/pull/6048

See https://github.com/openjs-foundation/project-status/issues/2
2024-11-05 17:51:39 +00:00
Jordan Harband
ccf6d16017
[meta] disable blank issues 2024-11-04 15:07:16 +00:00
Jordan Harband
ba98270442
[meta] update issue template 2024-11-04 15:01:26 +00:00
Jordan Harband
1be4257e96
[Tests] update mocks 2024-10-31 14:23:36 -07:00
Cheerag Patel
9c9ff4bac0
[meta] Rename .github/ISSUE_TEMPLATE.md to .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md
Moved issue template into ISSUE_TEMPLATE folder
2024-10-30 14:03:05 -07:00
Jordan Harband
51ea809d63
[Tests] ensure that unit tests use only mocked LTS names 2024-10-30 23:41:50 -07:00
Jordan Harband
6b70c40f15
[Fix] nvm_install_latest_npm: avoid unbound variable
Fixes #3447
2024-10-22 22:02:01 -07:00
Reetik Rajan
5dc31ac51b
[patch] give a more helpful message when lts alias is mistakenly used 2024-10-05 09:21:42 +05:30
Jordan Harband
da2720a429
[Fix] nvm ls, nvm alias, nvm install: error when an LTS name is invalid 2024-09-04 13:55:11 -07:00
Jordan Harband
9fb9dec710
[Fix] nvm_normalize_lts: error when an LTS name is not lowercase
Fixes #3417
2024-09-04 13:54:41 -07:00
Jordan Harband
9a28dbd394
[actions] use node/install instead of node/run 2024-08-28 11:28:52 -07:00
Jordan Harband
179d45050b
v0.40.1 2024-08-27 13:44:15 -07:00
Jordan Harband
ff7634577b
[Tests] fix broken tests exposed by 863bd63
Leaves 2 non-executable, + some TODOs
2024-08-27 12:46:40 -07:00
Jordan Harband
0ce8f5a52f
[Fix] nvm_download: ensure all args are quoted
Fixes #3411.
2024-08-20 22:33:38 -07:00
Jordan Harband
863bd63cfa
[Tests] set proper permissions on test files 2024-08-23 17:23:12 -07:00
Jordan Harband
0d53381666
[Tests] move sourcing suite to GHA 2024-08-22 13:30:55 -07:00
Jordan Harband
df70535248
[Fix] nvm_auto: Fix bug introduced in c31a867 2024-08-21 10:54:19 -07:00
Jordan Harband
c31a867c46
[Fix] --save: avoid a conflict with set -e
Fixes #3405.
2024-08-10 15:52:24 +12:00
Jordan Harband
a8c418558a
[Refactor] --save: clean up some usage 2024-08-20 16:21:45 -07:00
Jordan Harband
d5e2c92a25
[Fix] nvm_has_colors: avoid an aliased tput
Fixes #3413
2024-08-20 09:23:45 -07:00
Jordan Harband
81f18bc445
[patch] install.sh: fix node capitalization 2024-08-09 13:46:16 +12:00
Jordan Harband
4beab63631
[Fix] declare an unbound variable
Fixes #3402
2024-08-07 17:38:37 +12:00
Jordan Harband
14acd3dcdd
[Fix] nvm install -b: do not attempt to download source on a failed binary download with -b
Fixes #3399
2024-08-01 10:35:37 -07:00
Jordan Harband
271720ebfc
[Fix] nvm install -b: when no binary is available, fail and output a clear message 2024-08-01 13:57:22 -07:00
Jordan Harband
423ee82b4c
[Tests] fix nvm ls-remote unit test 2024-08-01 10:22:28 -07:00
Jordan Harband
deac4e0932
v0.40.0 2024-07-30 12:50:18 -07:00
Jordan Harband
b5118ac365
[Dev Deps] update semver 2024-07-30 11:35:15 -07:00
Jordan Harband
24deac7ac5
[readme] add OpenJS Ecosystem Sustainability Program partner
- https://openjsf.org/ecosystem-sustainability-program
2024-07-30 10:08:48 -07:00
Jordan Harband
ff1257e8e3
[Refactor] nvm_has_colors: also check the env var 2024-07-28 18:01:14 -07:00
Jordan Harband
87a709741f
[Fix] nvm_get_default_packages: use awk for more reliable file processing
See db19450caa

Fixes #3382
2024-07-28 10:02:08 -07:00
Martin
f439acda4a
[New] nvm use/nvm install: add --save option
Fixes #2849.

Co-authored-by: Martin <maartin00000@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2022-08-29 16:01:36 +01:00
Ally Summers
dd89af53f5
[patch] Fix issue where zsh global aliases would break nvm help
Fix issue with the color codes in the nvm help text where zsh global aliases would display an inline error in the nvm help text.
2024-07-26 03:35:55 +10:00
David Welch
bd090ef7f8
[New] Add support for NVM_AUTH_HEADER env var
Closes #3366

Co-authored-by: David Welch <david@davidwelch.co>
Co-authored-by: Andre Kradolfer <narfdre@gmail.com>
2024-06-21 08:55:22 -06:00
Jordan Harband
4c7d899447
[Tests] ignore travis-ci env vars; improve debug output 2024-07-26 12:04:07 -07:00
Andre Kradolfer
80cb39d712
[debug] adding logging to makefile 2024-07-22 14:07:07 -06:00
Jordan Harband
93277112ae
[Fix] install-latest-npm: npm ^8.7 breaks npm ls with file: deps 2024-07-26 09:16:03 -07:00
Jordan Harband
762f9ef9d1
[Tests] only install python 2.7 if not already installed
See ee6f7667 / #3067
2024-07-06 10:29:55 -05:00
Jordan Harband
e597bb208e
[Tests] use a better JSON parsing implementation 2024-06-10 11:33:12 -07:00
Jordan Harband
aa427ad396
[Tests] ensure travis can access public repo submodules 2024-06-10 09:15:16 -07:00
Jordan Harband
c20db2ab86
[actions] improve default action permissions 2024-06-10 08:59:48 -07:00
Jordan Harband
29dce5edfd
[New] allow .nvmrc files to support comments
In theory, `npx nvmrc` can now be used to validate an `.nvmrc` file that `nvm` will support. Allowances have been made for future extensibility, and aliases may no longer contain a `#`.

Fixes #3336. Closes #2288.

Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Yash Singh <saiansh2525@gmail.com>
2024-06-07 10:13:00 -07:00
Jordan Harband
95081f0bc2
[readme] update CII badge URLs 2024-06-06 14:19:11 -07:00
Jordan Harband
1750b8d327
[actions] update vampire/setup-wsl action 2024-05-30 12:37:36 -07:00
Jordan Harband
97093dc1b3
[Dev Deps] update markdown-link-check, semver 2024-05-30 12:36:26 -07:00
Jordan Harband
811c039e2b
[actions] finisher tweaks 2024-03-08 22:28:53 -08:00
Huy Z
294ff9e3aa
[readme] Fix uninstall instructions
`nvm unload` will unset NVM_DIR. So gotta save NVM_DIR first.
2024-02-13 03:39:07 -08:00
Raphael Boidol
c24c3134a7
[actions] update action versions to use node 20 2024-02-18 21:56:53 +01:00
Jordi Paris Ferrer
c82e7a6f62
Fix typo in WSL section of README
`u` -> `you`
2024-02-17 16:39:36 -08:00
jbidad
4e2a71ba9b
[Docs] add nvm unload to uninstall nvm instructions 2024-01-18 12:07:01 +03:30
Jordan Harband
6c9cd2f2d1
[security] fix typo in threat model 2023-12-15 09:46:35 -08:00
Jordan Harband
bab86d5de5
v0.39.7 2023-12-05 21:50:27 -08:00
Jordan Harband
d86f270438
[Fix] use \hash instead of command hash for zsh
See #3239; Fixes #3247; Closes #3246
2023-12-05 21:48:51 -08:00
Jordan Harband
c73009f503
v0.39.6 2023-12-04 22:03:25 -08:00
Ben Wiley
7aee54b76c
[readme] reorganize “deeper shell integration” instructions 2017-06-29 14:23:03 -04:00
Chris Meyers
6262b5a666
[readme] rearrange install args 2023-10-23 21:48:11 -06:00
Ellet
925cff2c78
[readme] update M1 to “Apple Silicon” because of M2 and M3; fix typos 2023-12-01 05:56:48 +03:00
Jordan Harband
b1fa143dd8
[Fix] nvm_get_mirror: ensure only a valid URL is allowed 2023-12-02 14:44:46 -08:00
Jordan Harband
cc765cc000
[Fix] avoid overridden hash
Fixes #3239
2023-11-24 20:42:53 -08:00
Jordan Harband
99646ee600
[security] add threat model 2023-11-15 10:10:29 -08:00
Jordan Harband
b356fab4b4
[meta] fix gitattributes to properly recognize images as binary 2023-11-22 22:29:01 -08:00
Hao Cheng
064f2597d1
[readme] fix level of headings 2023-11-12 14:18:39 +01:00
Jordan Harband
6b15796f66
[Tests] temporarily allow cygwin tests to fail 2023-12-04 15:49:09 -08:00
Jordan Harband
3e51872b98
[Tests] temporarily allow WSL tests to fail
See https://github.com/Vampire/setup-wsl/issues/50 / https://github.com/actions/runner-images/discussions/8791
2023-12-04 13:06:24 -08:00
Jordan Harband
4bdd57ba0f
[Fix] install.sh: when NVM_INSTALL_GITHUB_REPO is set, issue a warning
This should only annoy those testing their PRs; real users should never set this env var
2023-11-02 21:10:09 -07:00
Jordan Harband
d02ddcac2c
[Fix] nvm_get_mirror: disallow some non-URL characters
This should be improved in the future, but is fine for now
2023-11-01 21:01:28 -07:00
Andrius Solopovas
ef7fc2f2c0
[Fix] nvm_get_arch: proper value for alpine linux 2023-09-30 23:54:11 +01:00
Jordan Harband
b64e5474ea
[Tests] ensure windows tests install a node that actually works
- disable failing Alpine tests
 - disable Ubuntu-18.04 tests on node 18+
 - add Ubuntu-20.04 tests
2023-11-01 16:12:12 -07:00
Jordan Harband
1f970ccb7a
[Fix] nvm_normalize_lts: switch from expr to case
avoids `expr: warning: ^lts/-[1-9][0-9]*: using ^ as the first character of a basic regular expression is not portable; it is ignored`
2023-11-01 12:24:29 -07:00
Jordan Harband
6743aef70c
[New] nvm_resolve_alias: only resolve one line of a multiline alias file 2023-10-23 14:41:14 -07:00
Jordan Harband
10cdda081f
[Tests] update test mocks (new LTS, iron) 2023-10-25 15:39:12 -07:00
Jordan Harband
8241287349
[New] aliases: skip leading blank lines in alias file 2023-10-23 14:06:19 -07:00
Jordan Harband
6aeab3349c
[Robustness] nvm_list_aliases: avoid overwritten sort 2023-10-23 14:05:37 -07:00
Jordan Harband
bfce5889f7
[Test] update test mocks 2023-10-23 14:53:39 -07:00
Justin Dhillon
fd412645ca
[readme] add section on bare nvm install 2023-10-23 10:25:26 -07:00
Jordan Harband
2426a0c4b2
[security] add prose explaining OpenSSF CII Best Practices badge results
Fixes https://github.com/openjs-foundation/security-collab-space/issues/35.
2023-10-20 15:58:27 -07:00
Michael Di Prisco
8a83b36688
[readme] missing parenthesis 2023-10-06 02:36:26 +02:00
Jordan Harband
414e8d426f
[Tests] switch cygwin mirror 2023-10-09 14:50:40 -07:00
zhangdiandian
1b102ab9a6
[Tests] fix filename typo
Signed-off-by: zhangdiandian <1635468471@qq.com>
2023-10-09 07:31:04 +00:00
Peter Dave Hello
d4a733e4d8
[Dockerfile] Remove apt src disabling, no longer needed 2023-09-19 20:03:01 +08:00
Nam
1de3333651
[Dockerfile] [Fix] add missing leading slash in path 2023-09-18 17:42:40 +07:00
Jordan Harband
1eaaada499
[Perf] nvm_check_file_permissions: do not traverse into symlinks 2023-08-25 22:49:41 -07:00
Jordan Harband
c92adb3c47
v0.39.5 2023-08-21 21:10:10 -07:00
Oliver Henshaw
15eba7b7e6
[Fix] nvm_strip_path: Preserve leading/trailing colons
Path lists in environmental variables often give special meaning to
empty entries (e.g. in PATH or MANPATH). These are represented by
leading or trailing colons, or by doubled colons in the middle of the
list.

Adjust the awk invocation to correctly deal with trailing colons by
printing the separator before every field except the first, and then
printing the final separator that is read from the input - this will
either be a colon or the null string. This preserves leading and
trailing colons in all cases while not adding extra colons in the wrong
place.

Add test to confirm the correct behaviour.

Fixes #3144
2023-06-21 15:47:52 +01:00
heungjun.park
a1601eddb8
[readme] add examples of setting specific versions as default
Co-authored-by: heungjun.park <rockheung@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2023-07-20 17:39:37 +09:00
Jordan Harband
324b81a722
[Fix] allow checksums to pass with a leading backslash
See https://unix.stackexchange.com/a/555061/137489
2023-08-06 14:51:48 +12:00
Jordan Harband
55075db96d
[Tests] add some nvm_do_install tests 2022-12-27 22:57:07 -08:00
Jordan Harband
4618ce0aa1
[Tests] a cleaner name for the windows tests 2022-12-27 22:32:09 -08:00
Jordan Harband
3afdce0a2c
[Fix] nvm install-latest-npm: ensure npm 10 does not install on unsupported nodes
See https://github.com/npm/cli/pull/6674
2023-07-26 13:21:03 -07:00
Jordan Harband
8fbf8ab694
v0.39.4 2023-07-24 18:29:54 -07:00
Jordan Harband
4fc91d408c
[Dev Deps] update markdown-link-check, semver 2023-07-24 18:24:39 -07:00
Emmanuel Ogbizi
f86847fdd2
[readme] add nvshim tool alongside avn 2020-04-15 19:27:44 -04:00
emmanuel-ferdman
9a769630d7
[readme] fix typo in resolv.conf filename
Signed-off-by: emmanuel-ferdman <35470921+emmanuel-ferdman@users.noreply.github.com>
2023-06-18 15:41:40 +03:00
Augustin Mauroy
c26422a03e
[readme] Update logo header 2023-06-05 10:34:20 +02:00
milesfrain
7c3cd81ad9
[readme] Add instructions on how to install without editing shell config
I had to dig into #2410 to learn about the `PROFILE=/dev/null` technique to install without appending to my shell config. Figured this note would be good to add in the main installation docs.
Also added a note on how to do this as a one-liner which was not obvious for me.
2023-04-25 13:49:16 -07:00
Deniz Eren Evrendilek
0ebda7eea3
[meta] Remove unavailable testing script
Fixes #3104
2023-05-01 11:23:38 -07:00
Deniz
5410ae57ba
[Fix] fix node download link for armv8l
Fixes #3035
2023-04-29 16:41:31 -07:00
Spike Grobstein
70aa611abc
[Fix] nvm exec: no longer error with '-q: invalid option' for zsh users
the `nvm.sh` file assigns and exports an `NVM_CD_FLAGS` variable if it
was sourced from a zsh shell. the fact that it's exported means that
it'll be assigned in all child processes, including the `nvm-exec`
script, which uses bash as the interpreter.

Bash's `cd` command doesn't have a `-q` flag, so if the `NVM_CD_FLAGS`
is assigned `-q`, the script will error out and incorrectly claim that
the node version isn't installed.

this also manifests itself in the `nvm exec` command.

Example:

```console
$ nvm exec 16.14.0 npm --version
Running node v16.14.0 (npm v8.3.1)
/Users/<ME>/.nvm/nvm.sh: line 28: cd: -q: invalid option
cd: usage: cd [-L|[-P [-e]] [-@]] [dir]
both the tree and the node path are required
N/A: version "v16.14.0 -> N/A" is not yet installed.

You need to run "nvm install v16.14.0" to install it before using it.
```

To address this, we unset the `NVM_CD_FLAGS` at the start of the
`nvm-exec` script, before loading `nvm.sh`.
2023-04-21 20:40:01 -07:00
Jordan Harband
c08b38a2a4
[Fix] nvm_print_npm_version: if npm exists but its node crashes, do not print the npm version 2023-04-28 10:57:57 -07:00
Jordan Harband
a07cd41af1
[Fix] nvm_ls_current: when node is present but crashes immediately, echo "none" 2023-04-28 10:55:03 -07:00
JC (Jonathan Chen)
d1a22a63bd
[readme] cdnvm function: fix shellcheck errors
Resolves #3081
2023-04-09 09:21:56 -04:00
Leo Zlotnikov
0d9b5c2a00
[Fix] fix directory traversal when workdir path is not readable 2023-04-08 17:24:41 +01:00
Peter Dave Hello
44e1d9c911
[Dockerfile] Update base image from Ubuntu 20.04 to 22.04, cc #2877 2023-04-06 01:22:10 +08:00
Jordan Harband
b1331c20b0
[Tests] add unit tests for nvm_download_artifact 2023-04-06 09:23:33 -07:00
Peter Dave Hello
766341fca1
[readme] Update Travis CI badge and link url
travis-ci.org is deprecated and replaced by app.travis-ci.com for a while
2023-04-03 22:50:48 +08:00
Jordan Harband
946da2e743
[Dev Deps] update markdown-link-check 2023-03-22 16:20:48 -07:00
Dennis
dde04f9392
[Fix] recognize 32Bit docker container and use x86 arch 2023-03-22 14:52:40 -07:00
William Baker
ffcb5213e2
[Perf] Improve performance of listing aliases
Fixes #3054
2023-03-10 00:53:29 -05:00
Jordan Harband
ea3b65f02e
[Tests] npm bin has been removed 2023-03-21 13:31:52 -07:00
Qasim Abdullah
ee6f766712
[Tests] downgrade python to v2 on travis
- TCI Support
 - python 2.7
 - skip build-essential
2023-03-21 22:45:38 +05:00
Nicolas signed-log FORMICHELLA
edacf8275e
[Fix] Remove unneeded call to ls in nvm_arch
Remove the call to `ls` that was used to determine the symlink
destination

Reasoning :

* `od` resolves symlink itself due to the use of `fopen`
* Prevent the behaviour of `od` which will hang if the filename is
  empty (i.e. `/sbin/init` missing) as it will be waiting for `stdin`
  compared to quitting with error if the file just doesn't exist

Fixes #3006
2023-01-22 11:48:59 +01:00
Jordan Harband
f36516b472
[Tests] move install script tests to github actions 2022-10-26 14:47:18 -07:00
Jordan Harband
dc691121b8
[Tests] improve debug output on failure 2022-12-27 21:41:39 -08:00
Jordan Harband
ce35311657
[Tests] force the NVM_DIR to the expected location, for tests 2022-12-27 21:40:48 -08:00
Thomas Levine
fe06825a96
[tests] Update urchin repository link 2022-12-25 10:38:26 +00:00
Jordan Harband
a60ac08a80
[actions] allow nvm to be installed 2022-12-26 13:22:07 -08:00
Jordan Harband
552db40622
v0.39.3 2022-12-23 12:57:56 -08:00
Jordan Harband
788c0a425e
[meta] use HEAD instead of master where possible 2022-12-23 12:53:40 -08:00
Dani Schuhman
333c52ec04
[meta] Improve contributors documentation
Incorporates old Contributing.md with more thorough details on how to contribute, create bug reports, set up the dev environment, and creating PR's itself.
2022-04-15 11:59:16 -04:00
mattjaf
59f448d595
[Docs] added WSL troubleshooting with solution to (6) Could not resolve host: raw.githubusercontent.com
Fixes #2958.
2022-11-30 19:25:20 -08:00
Jordan Harband
d0bc227127
[Tests] update test mocks 2022-12-22 16:07:00 -08:00
Jordan Harband
bf438742a7
[Tests] move installation_node tests back to xenial 2022-12-22 16:16:10 -08:00
Jordan Harband
447940acb3
[Tests] move tests that fail on focal to a separate suite that runs on xenial 2022-12-22 11:26:27 -08:00
Jordan Harband
0ec2ca979c
[Tests] update travis to use focal
- xenial can't build node 18
 - bionic can't build node 0.6 or 18
2022-10-26 11:12:19 -07:00
Jordan Harband
b86c91efe3
[actions] fix latest-npm tests so they use this repo’s nvm instead of the last published one 2022-12-22 15:27:46 -08:00
Jordan Harband
ac357c59ef
[Fix] nvm install-latest-npm: npm v6.14.18 can not be installed from npm < v4.4.4 2022-12-21 14:28:15 -08:00
Jordan Harband
abe5e30a9d
[shellcheck] remove duplicate function 2022-12-22 13:00:12 -08:00
Jordan Harband
4c4b0d64ed
[Tests] fix nvm_list_aliases test to use mocks for LTS aliases 2022-10-26 10:31:26 -07:00
Jordan Harband
e6fa80cb61
[Dev Deps] update doctoc, markdown-link-check, replace, semver 2022-10-26 10:13:39 -07:00
Jordan Harband
1f4bb91ae6
[Fix] ensure this variable is bound
Fixes #2926
2022-10-26 10:12:06 -07:00
Jordan Harband
924d77cc90
[Fix] debug: correct mistaken -V to --version from #2922 2022-10-24 10:51:20 -07:00
ryenus
095a4ca655
[Fix] debug: awk: not an option: --version
On Debian, the default awk/mawk doesn't support the '--version' option;
instead there's mawk-specific '-W version'.
2022-10-21 16:48:00 +08:00
ryenus
9721791563
[Fix] grep: warning: stray \ before /
No need to escape the `/` char in a grep pattern.
This is to fix the below error when using newer grep with `nvm_command_info`

> $ nvm_command_info curl
> grep: warning: stray \ before /
> /usr/bin/curl

This happens with at least GNU grep 3.8 version.
2022-10-20 10:49:43 +08:00
ryenus
89d6cdd6cf
[Fix] improve backward compatibility for non-gnu awk
Adding function alen(arr) since length(arr) is GNU extension.
Fixes #2916
2022-10-18 11:25:12 +08:00
Jordan Harband
df84c77a81
[actions] update some actions deps 2022-10-16 17:51:14 -07:00
epoweripione
fe6268c021
[Fix] nvm install error unknown condition: -ne
Fixes #2914

Co-authored-by: epoweripione <siyuwuxin@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2022-10-15 20:25:52 +08:00
Jordan Harband
df01d81128
[Refactor] add nvm_wrap_with_color_code; allow no color code 2022-10-13 20:16:42 -07:00
Jordan Harband
0ccd099bff
v0.39.2 2022-10-13 16:25:25 -07:00
Jordan Harband
f062cca179
[Refactor] nvm install/nvm_install_default_packages: move "get" logic inside helper 2022-10-13 15:03:36 -07:00
Jordan Harband
0698ede92d
[Tests] update test mocks 2022-10-13 12:08:31 -07:00
Jordan Harband
71a73b17cf
[Fix] --help: proper default NVM_COLORS info 2022-10-13 13:34:43 -07:00
Jordan Harband
0ae8409f4f
[Fix] nvm install-latest-npm: ensure npm 9 does not install on unsupported nodes 2022-09-08 14:59:25 -07:00
ryenus
5e9791c4f8
[perf] nvm_print_versions: re-implement using awk
reducing `nvm ls-remote` from almost 20s to below 2s.

Signed-off-by: ryenus <ryenus@gmail.com>
2022-06-05 13:27:03 +08:00
Maxim Lepekha
7c929f8742
[Fix] install.sh: support ~/.zprofile 2022-09-21 22:38:50 +02:00
Josh Kelley
c6269e0ac2
[Fix] Don't override Mac M1 architecture for node ^14.17
Fixes #2743

Co-authored-by: Josh Kelley <joshkel@gmail.com>
Co-authored-by: Raz Luvaton <16746759+rluvaton@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2022-03-30 10:53:01 -04:00
BatemaDevelopment
28b3b0e324
[readme] Update Alpine Linux Section
- Update install directions to include `python3`, instead of `python2`, which is deprecated since Alpine 3.13.
2022-09-27 06:44:13 -04:00
Peter Dave Hello
b133f6619d
[Dockerfile] Update base image from Ubuntu 18.04 to 20.04, cc #2877 2022-09-07 16:36:29 +08:00
Robert Shuford
4893128c61
[readme] optimize calling of nvm version in zsh 2022-08-25 21:12:36 -04:00
etienne-miralytik
8fd948001e
[readme] Fix Ansible Linting Errors
Fixes #2860.

This fixes these two linting errors:
- fqcn-builtins: Use FQCN for builtin actions.
- name: All names should start with an uppercase letter. (name[casing])
2022-08-24 18:58:38 +02:00
Jer Wilson
5a4e9184f1
[readme] cdnvm(): handle failed dir change
If cd command fails, return whatever cd returned, instead of marching ahead
2022-06-27 17:21:45 -07:00
SnipUndercover
95269ff055
[readme] Fix Git Install instruction list structure 2022-05-26 01:13:00 +02:00
Danny Neumann
2cfced740a
[Docs] Add note about creating .bashrc file *as well as* .bash_profile.
My problem was that I didn't have EITHER file, and hopefully the notes will help someone else reading the docs.
2022-01-27 10:53:36 -08:00
Robert Shuford
35758b75ed
[Tests] github actions removed homebrew and broke shellcheck
See https://github.com/actions/runner-images/issues/6283
2022-10-06 11:13:47 -04:00
Robert Shuford
d451e261ed
[Tests] node 18 no longer builds in travis-ci 2022-10-05 10:09:00 -04:00
Jordan Harband
a82edf40ba
[Robustness] avoid a clobbered ls
Fixes #2824
2022-06-02 12:25:55 -07:00
Jordan Harband
ef3b20c21e
[readme] add logo 2022-04-22 16:53:49 -07:00
Dani Schuhman
01886b4243
[meta] Update CODE_OF_CONDUCT to current version 2022-04-15 10:56:26 -04:00
Jordan Harband
bd083ff367
[readme] minor cleanup 2022-04-11 14:09:37 -07:00
deepakchethan
9e884b8d7b
[Fix] nvm install: show proper version in .nvmrc install instructions 2022-03-22 18:58:18 +05:30
Ponder
7d86701067
[readme] fish: send output from load_nvm to /dev/stderr 2022-04-01 13:00:58 -04:00
legendecas
c367d7daa0
[Docs] fix fish load_nvm variable interpolations 2022-03-28 23:28:53 +08:00
Antony Tse
d157cac689
[readme] Correct typos in "Macs with M1 chip" section 2022-03-09 09:41:48 +00:00
Jordan Harband
39d9a42c35
[Fix] install.sh: error out if the install instructions are not followed 2022-02-08 10:40:11 -08:00
Kai
2c0c34f10e
[Docs] HTTP => HTTPS 2022-01-16 14:25:11 +01:00
Jordan Harband
c2f740ab38
[patch] HTTP -> HTTPS 2022-01-18 12:49:57 -08:00
Jordan Harband
6cfaede5a0
[Fix] install: better error message when xcode command line tools are needed
Fixes #2697. Fixes #2663.
2021-11-27 22:16:14 -08:00
Luke Arms
1875fe8b40
[Fix] avoid OpenBSD nvm install error when /sbin/init doesn't exist
`nvm install` fails with "Binary download failed, trying source" when
- running on Bash;
- errtrace (`set -E`) is enabled;
- an ERR trap uses `exit` to return a non-zero status; and
- /sbin/init doesn't exist.

Resolved by moving `ls -dl /sbin/init` to the following `if` statement.
In this context, returning non-zero isn't an error and the ERR trap
isn't executed.
2021-12-26 15:31:53 +11:00
Luke Arms
81f0f3ec19
[Fix] set -E: Add test for node install on Bash with an ERR trap and set -E 2021-12-27 16:02:25 +11:00
lsfxz
fb4538b360
[Fix] add missing local (handle nonexisting /sbin/init a bit more cleanly) 2021-11-17 16:59:53 +01:00
Luke LaFountaine
d004c6b064
[readme] clarify instructions for running Node on M1 Mac 2021-12-03 16:52:18 -05:00
Bob Bregant II
79ad72d116
[Fix] Update nvm_extract_tarball to support OpenBSD
Fixes #2660.
2021-12-19 02:58:18 +00:00
Bob Bregant II
ccd442d833
[Refactor] add nvm_extract_tarball to consolidate extraction logic 2021-12-19 02:58:18 +00:00
Jordan Harband
9600617c52
v0.39.1 2021-12-17 14:55:52 -08:00
Jordan Harband
5cc74a6736
[Tests] fix failing test 2021-12-17 13:21:29 -08:00
Jordan Harband
aa57406ede
[Fix] ensure unload removes nvm_normalize_lts 2021-12-17 13:55:14 -08:00
Jordan Harband
0f62be6fdd
[Dev Deps] update markdown-link-check 2021-12-17 12:37:15 -08:00
Jordan Harband
c4c7690dec
[Fix] ls-remote/install: support lts/-X patterns in installs
Fixes #2692
2021-12-16 23:01:05 -08:00
Jordan Harband
aed1d732d7
[Fix] ls-remote/install: properly handle lts/x patterns 2021-12-16 22:58:06 -08:00
Jordan Harband
0b4cd8df6c
[Refactor] create nvm_normalize_lts helper 2021-12-16 22:55:02 -08:00
Jordan Harband
430860a8be
[Fix] nvm alias/nvm_list_aliases: support lts/ aliases
See #2692
2021-12-16 15:54:38 -08:00
Jordan Harband
2459d17741
[Tests] update test mocks 2021-12-16 23:13:15 -08:00
Varun Sharma
6cc90a4b8d
[actions] add step security runner 2021-11-22 07:20:50 -08:00
Jordan Harband
81fc05684d
[Tests] nvm_get_download_slug: add unit tests 2021-12-02 23:33:20 -08:00
Ankit Kumar
328dd5004e
[Fix] nvm_get_download_slug: better architecture selection for M1 Macs
If the node version is below 16.0.0 then nvm will select x86_64 architecture, else arm64 architecture.
2021-11-21 15:59:39 +05:30
Jérôme Foray
4856407d26
[Fix] install: fix method=script install condition
Fixes #2665; see 8937917
2021-11-30 16:07:22 +01:00
Jordan Harband
275001b066
[Tests] fix windows WSL tests 2021-11-25 19:35:39 -08:00
Jordan Harband
89379176ac
[Fix] install: properly check for curl/wget 2021-11-25 14:26:35 -08:00
Robert Elliot
30486b9bd9
[readme] Balance the if statement in bash example
Nesting the `elif` at the same level as the `if` and `fi` makes it clear which code applies to which branch (no .nvmrc file / found .nvmrc file).

I wasted a while looking at it trying to work out how it did anything if there was a .nvmrc file, because obviously the `if` didn't match and I couldn't see the `elif` branch.
2021-11-22 14:34:43 +00:00
Ian Grayson
e9b26938b9
[readme] Describe another failure case for installing node versions from source on mac arm64 machines.
It seems to be related to https://github.com/nodejs/node/issues/39313 (which describes a similar issue).
2021-11-15 04:23:42 -08:00
Jordan Harband
ccd98f7fcb
[Dev Deps] update doctoc 2021-11-19 08:59:37 -08:00
Jordan Harband
2f40eeef2e
[shellcheck] apply v0.8.0 updates 2021-11-19 08:53:43 -08:00
Nix
c9e7bb2da1
[Fix] install script: Add --no-pager option to git branch 2021-10-23 22:23:55 +09:00
Wu Jiang
a284af9228
[New] Add OpenBSD support 2016-04-14 20:57:10 -04:00
Jordan Harband
5b3d188b83
v0.39.0 2021-10-07 10:11:35 -07:00
Jordan Harband
e8f485bb63
[Dev Deps] update doctoc, markdown-link-check 2021-10-07 10:08:53 -07:00
Simon East
055af09d24
[readme] link "Windows WSL" down to the "important notes" section 2021-05-04 15:56:53 +10:00
Matteo De Wint
93e0070a44
[Fix] nvm_die_on_prefix: filter prefixed env vars on name only, ignoring values 2020-11-28 15:16:35 +01:00
Felipe Alexandre Rodrigues
10189bf4cb
[readme] Add bash_completion in "manual install" section 2021-10-05 10:47:56 -03:00
Jordan Harband
da5baa005b
[Tests] use a matrix on the nvm install-latest-npm tests 2021-10-05 16:14:05 -07:00
Jordan Harband
ebbd30eb7f
[Fix] nvm install-latest-npm: ensure npm 8 does not install on unsupported nodes 2021-10-05 15:13:45 -07:00
Rick Button
2bda9fd97e
[Tests] blacklist expired LetsEncrypt CA
workaround for TravisCI's ubuntu 16.04
2021-10-06 01:50:44 -04:00
Peter Dave Hello
7b530edd3a
[Docs] Use absolute URL for #606 in README.md
Since markdown-link-check hasn't support relative links, to make the
test passed, move this link to use absolute URL so that we can introduce
the new test. cc tcort/markdown-link-check#10
2017-11-05 04:07:37 +08:00
Peter Dave Hello
1afd4f3566
[Tests] Add markdown-link-check script
This uses the npm package `markdown-link-check` to check if all the links in the documentation are alive.
2017-11-05 04:06:36 +08:00
Kaito Udagawa
53f9ba8336
[Refactor] Use awk for path stripping
This works with paths which contains regex meta characters.
2016-12-23 01:03:41 +09:00
Jordan Harband
07c02d43fe
[Tests] nvm install-latest-npm: node < 0.10 breaks with npm with dropped support for TLS < 1.2 2021-09-29 10:47:34 -07:00
Alister Norris
59b0b3942c
[readme] Add quick intro to nvm
Allow newbies to get a quick understanding of how `nvm` works right from the start.
2016-12-06 15:14:08 +00:00
Peter Dave Hello
7bbc57355d
[Tests] Print shell version in Travis CI 2017-04-02 07:33:49 +08:00
Alex Sabau
47f0b32155
[readme] Add info to restart bash if verification not working in verification section 2018-02-25 21:46:31 +01:00
James Stroud
91bd22aa57
[readme] fixed small typo afew to a few
also gave more up to date versions for example of  `nvm install` and `nvm which` as well as your pointer section
I love your project by the way.
2021-06-04 15:15:17 -04:00
Tim Connolly
ca897ac6d5
[readme] Avoid infinite loop in cdnvm() 2021-09-22 16:25:28 +10:00
Axel Svensson
11d71ab24b
[Fix] Regression in 2dad045
Fixes #2599
2021-09-24 01:56:47 +02:00
Georgi Chochov
4471b6beb6
[readme] remove duplicate word 'run' 2021-09-26 09:47:50 +00:00
Nikita N
cc6915e216
[readme] updated automatic call script for bash
Bash terminal was throwing error: `bash: cd: too many arguments` when directory had some spaces in the name.
The quotes around `$PWD` fixes this issue
2021-09-21 23:57:25 +03:00
Jordan Harband
b6b6e685a3
[Fix] set -a: when this option is set, some sh shells break
Fixes #2574
2021-09-14 23:26:31 -07:00
Gilad Barnea
d91087c333
[Fix] bash_completion: be robust when cd is overridden 2021-09-13 15:26:40 +03:00
Step Security
59532c74c6
[actions] restrict permissions for GITHUB_TOKEN 2021-09-10 06:09:45 +00:00
Jordan Harband
2dad0455ec
[Fix] nvm_die_on_prefix: avoid grepping env functions in bash
ironically, nvm itself has functions that matched this grep.
2021-09-08 23:49:16 -07:00
Jordan Harband
f03f69508e
[Fix] reinstall-packages: handle global symlink locations properly
This is a regression caused by npm ls -g in npm 7 no longer returning absolute paths.
2021-09-07 10:14:18 -07:00
Jordan Harband
fa63399991
[Tests] postcss v7.0.36 stopped working on node 0.10; downgrade to v4 2021-09-09 00:05:09 -07:00
Kevin Stolp
291c7c4c47
[Fix] nvm_ls_remote_index_tab: handle long version lists 2021-09-03 23:40:13 -07:00
Jordan Harband
c169d622ff
[Tests] update mocks 2021-09-04 08:57:36 -07:00
Jordan Harband
5b77f7d023
[Fix] nvm ls/nvm alias/nvm_list_aliases: zsh: when no LTS aliases, no error
Fixes #2575.
2021-09-01 10:06:32 -07:00
Jordan Harband
fd78c0101e
[Tests] disable fail-fast 2021-08-31 15:28:41 -07:00
Peter Dave Hello
678a827978 [Dockerfile] Update dated base image from Ubuntu 16.04 to 18.04 2021-08-31 02:03:30 +08:00
IYaksha
62d45af17e
[readme] fix typo regarding docker image base in Dockerfile 2021-08-30 19:20:03 +05:30
Jordan Harband
e0df5e92e3
[Robustness] avoid IFS shenanigans: quote arg count/return codes 2021-08-24 09:34:01 -07:00
Thomas Geirhovd
e98e9d9e4b
[Fix] install: Detect correct profile based on $SHELL var 2021-08-12 15:51:32 +02:00
Jordan Harband
812d6e4ab4
[actions] fix typo in dockerfile_lint job 2021-08-05 08:35:22 -07:00
Jordan Harband
7f2ccd51d4
[Fix] nvm_get_arch: suppress error output if /sbin does not exist
Introduced by #2469
2021-08-05 08:05:54 -07:00
Jordan Harband
7ba49f8f71
[actions] use node/install instead of node/run 2021-07-27 22:23:56 -07:00
Jordan Harband
eed0d0e85c
[meta] add project charter and governance 2021-04-26 12:56:08 -07:00
Jordan Harband
ad24e96fda
[shellcheck] disable additional -x warning from v0.7.2 2021-05-03 14:26:45 -07:00
Jordan Harband
b5165ecbe4
[shellcheck] update for new warnings in v0.7.2 2021-05-03 14:19:31 -07:00
Jordan Harband
fc87226b23
[readme] move License and Copyright notice sections to the bottom 2021-04-26 11:46:12 -07:00
Jordan Harband
f3caa06420
[meta] add OpenJS Foundation copyright notices/links 2021-04-26 11:42:03 -07:00
Jordan Harband
1527ac9d21
[readme] remove redundant "license" section text in favor of LICENSE.md 2021-04-26 11:41:29 -07:00
Jordan Harband
bd0ac1e96d
[meta] add SECURITY.md 2021-04-22 22:28:41 -07:00
akefirad
117486d4a7
[Fix] bash_completion: check if compinit is called before calling it
Fixes #2489.
2021-04-16 18:53:35 +02:00
Jordan Harband
07253ecd51
[actions] adjust shellcheck/windows tests to9 have a final "done" job 2021-04-15 22:34:40 -07:00
nmarghetti
f2582275f6
[New] maybe support Windows with WSL, MSYS, Cygwin 2021-01-02 00:03:24 +01:00
nmarghetti
d118be8fd4
[Tests] Add unit tests for nvm_is_version_installed 2021-02-21 18:48:43 +01:00
Leandro Facchinetti
5fcec573eb
[readme] Improve README about Macs with M1 chips
Mention that you must have Rosetta 2 installed and provide instructions on how to do it.
2021-04-05 16:25:41 +01:00
Botspot
779a34e6a9
[Fix] nvm_get_arch: Rasbperry Pi: armv7l with arm64 kernel, get correct arch
Co-authored-by: Botspot <54716352+Botspot@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Sladyn Nunes <sladynnunes98@gmail.com>
2021-03-22 14:56:25 -05:00
Sladyn Nunes
2b5e53fcd5
[Fix] install script: check the proper version; fetch tags also
Co-authored-by: Sladyn Nunes <sladynnunes98@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2021-04-01 19:06:40 +05:30
Jordan Harband
f534fde760
[Tests] node-gyp v8 breaks this test 2021-04-06 12:36:07 -07:00
Jordan Harband
3fea5493a4
v0.38.0 2021-03-29 12:49:10 -07:00
Jordan Harband
cfc7edac65
[Dev Deps] update dockerfile_lint, eclint, replace, semver 2021-03-29 12:49:02 -07:00
Jonathan Perret
c26bd935c0
[readme] M1 macs: Add nvm use command to clarify that it is required 2021-03-24 10:50:38 +01:00
Jonathan Perret
621ccc5d13
Clarify the M1 shell instructions
The instructions seemed to encourage the misconception that `arch -x86_64 zsh` somehow modifies the default architecture for `zsh`, an operation which would need to be "reverted".
In fact, `arch -x86_64 …` merely spawns a new process under the selected architecture.
2021-03-23 14:37:04 +01:00
Andrew Shield
b19d8dbbba
[readme] Update source command to include s in zsh 2021-03-18 16:07:24 +13:00
Jordan Harband
0579718308
[Fix] install script: define nvm_echo
- refactor `echo` to use `nvm_echo`

Per 589c2377fb (r48360520)
2021-03-17 09:07:15 -07:00
Marcin Kłopotek
8884fd32f6
[readme] Add nvs as one of the Windows alternatives
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2021-03-01 13:28:09 +01:00
Sladyn Nunes
25d2ebf2f8
[readme] add headings to certain sections
Fixes #2413.
2021-03-03 20:47:44 +05:30
Jordan Harband
9cb6a2b614
[Tests] ensure doctoc action fails when it should 2021-03-17 08:11:37 -07:00
artforlife
216ccd62f7
[readme] add commands to help troubleshoot without closing the current shell
Co-authored-by: artforlife <artforlife@users.noreply.github.com>
Co-authored-by: Sladyn Nunes <sladynnunes98@gmail.com>
2020-04-26 12:57:50 -05:00
Rodrigo Espinosa de los Monteros
4da7f101a2
[Fix] nvm_alias: ensure lts/-1 returns the one before lts/*
Fixes #2461
2021-03-11 16:22:31 -05:00
Jordan Harband
641f86879f
[Tests] update mocks
- make call count test depend on mocks
2021-03-11 13:06:41 -08:00
Lukman
1081ed161b
[New] install: add parallel build support for openbsd
Co-authored-by: Lukman <lukmaan.me@gmail.com>
Co-authored-by: Sladyn Nunes <sladynnunes98@gmail.com>
2020-12-26 22:23:35 +05:30
Vesa Vilhonen
52f67b3677
[Fix] exec: -- should stop argument parsing
Co-authored-by: Vesa Vilhonen <vesa@vilhonen.com>
Co-authored-by: Sladyn Nunes <sladynnunes98@gmail.com>
2020-11-20 13:06:28 +02:00
Sladyn Nunes
4fdef427e4
[New] install: add -b flag to skip building from source
Fixes #2114.
2021-02-16 19:34:23 +05:30
farmer
d9b11ba208
[readme] update cdnvm implementation 2021-02-19 21:12:03 +08:00
Jordan Harband
87f37909f2
[meta] add CODE_OF_CONDUCT.md 2021-02-15 14:33:44 -08:00
nmarghetti
7f6c0c053a
[Refactor] add nvm_install_binary_extract 2021-01-02 00:03:24 +01:00
nmarghetti
d396181ffb
[Refactor] add nvm_get_artifact_compression 2021-01-02 00:03:24 +01:00
shiyutim
a5742d4e9e
[readme] add install error tips 2021-01-07 10:51:33 +08:00
David Zulaica
d5c1441a83 [readme] Update M1 macOS troubleshooting instructions 2021-02-13 03:41:41 -08:00
Arshath
0fad5ec575
[readme] quote asterisk in shell command on --latest-npm example 2021-02-05 19:45:26 +05:30
Jordan Harband
0d14d7f6b7
[Dev Deps] update doctoc, replace, semver 2021-02-01 14:31:06 -08:00
Jordan Harband
4c11ab1ac6
[actions] update workflows 2021-02-01 14:39:36 -08:00
Matt Calthrop
49e806c77a
[readme] Add macOS troubleshooting instructions for M1 chip 2021-01-21 20:45:12 +00:00
Brandon L. Reiss
3243f7a082
[Fix] Fix potential unbound var error on nvm install
Fixes #2420. When using `nvm install` with an already installed
version, Bash (and potentially other shells) may emit an unbound
variable error when `set -u` is set. The presence of the error depends
on specific shell versions, but appears to happen in MacOS 11.1 (Big
Sur) using a recent Bash version installed via Homebrew (as of this
writing).

The fix accesses `ALIAS` correctly for the case where it is not set by
an `alias` option to `nvm install`.
2021-01-27 13:12:17 -05:00
Jordan Harband
015623ee6d
[Fix] avoid parse error with common omz global aliases, in nvm_print_color_code
Merge pull request #2365 from hosamaly/patch-1
2021-01-20 13:47:17 -08:00
nmarghetti
502089ae30 [New] install script: Allow installation from other repository also for git method 2021-01-14 00:10:19 +01:00
nmarghetti
589c2377fb
[Fix] install script: sync nvm_download implementation from nvm.sh 2021-01-13 02:26:38 +01:00
nmarghetti
60e78d3ec1
[Tests] Add unit test for nvm_download 2021-01-13 02:26:38 +01:00
nmarghetti
9f3397afa4
[Tests] add nvm_grep to install script, fix tests 2021-01-08 18:54:40 +01:00
Jordan Harband
436cda247e
[Fix] remove nvm_supports_source_options
Fixes #2387
2021-01-07 13:00:26 -08:00
nmarghetti
9849bf494d
[meta] Rename some files to be more cross platform 2021-01-04 00:49:05 +01:00
nmarghetti
4e9df33cb7
[New] install script: Allow installation from other repository 2020-12-27 10:09:29 +01:00
hjoshi123
f3fa157456
[Fix] bash_completion: move compinit before bashcompinit 2020-12-29 08:35:08 +05:30
hjoshi123
6982dee071
[Docs]: Updated README.md to include homebrew unsecure dirs warning
Closes #2361.
2020-12-22 17:29:32 +05:30
Hosam Aly
31c5c5c45a
[Fix] avoid parse error with common omz global aliases, in nvm_print_color_code
Fixes #2362. Fixes #2372.
2020-11-27 23:17:07 +00:00
Dena Burd
2fea55fdb5
[Tests] add test that fails without fix for #2362 2021-01-15 14:07:47 -08:00
Shiming
10399ed1bd
[Docs] source ./nvm.sh instead of nvm.sh, for zsh
Fixes #2204.
2020-04-27 16:11:09 +08:00
Jordan Harband
3c079f16c7
[shellcheck] fix silly shellcheck complaint 2020-12-21 23:47:25 -08:00
Jordan Harband
e76b2945c5
[Fix] relax $PREFIX checking, to accomodate npm exec
Fixes #2379.
2020-12-21 23:03:30 -08:00
Rui Chen
e48cb858a6
[Tests] .npm is now cached by default 2019-10-02 15:05:36 -04:00
Keith Lazuka
86708833c9
[Fix] Use local variable when looping over args
When the `nvm` function is called by a script which itself uses a variable
named `i`, `nvm` clobbers the caller's variable. This happens even if the
caller has declared its variable as local.

See note 1 on https://tldp.org/LDP/abs/html/localvar.html#FTN.AEN18568
2020-12-08 12:28:24 -05:00
David Moles
d4eba354b5 [Fix] install: Ignore npm command under $NVM_DIR when checking for global modules 2020-11-30 15:22:24 -08:00
Jordan Harband
ed321f1df0
[Tests] release: clobber local tags 2020-11-27 21:44:33 -08:00
Jordan Harband
4b947ec92d
v0.37.2 2020-11-27 21:34:28 -08:00
Jordan Harband
3b57dfec8d
Revert "[Fix] nvm_die_on_prefix: only grep lines starting with env var name" (#2347)
This reverts commit 21c0c05130.

Fixes #2360. Fixes #2364. Fixes #2366.
2020-11-27 21:28:12 -08:00
Jordan Harband
661a702cdd
v0.37.1 2020-11-24 21:16:43 -08:00
Jordan Harband
510b2fd44c
[Tests] fix eclint errors 2020-11-21 18:08:22 -08:00
Jordan Harband
80a4e06af9
[Tests] partially migrate to Github Actions 2020-11-07 00:09:08 -08:00
Alex Aubuchon
22902f04a3
[actions] Add release test workflow 2020-11-20 14:28:15 -05:00
Dena Burd
6848c16d53
[New] Added set-colors command. See details below:
This command allows users to replace default colors with their own custom colors.

 - top-level commands modified: alias, ls, ls-remote
 - helper functions added: nvm_echo_with_colors, nvm_err_with_colors,
nvm_set_colors, nvm_get_colors, nvm_print_color_code
 - functions modified: nvm_print_formatted_alias, nvm_print_versions, nvm_print_alias_path (implicitly), nvm_print_default_alias (implicitly), nvm_list_aliases (implicitly)

We added tests and info on using this command to the README!

Co-authored-by: Dena Burd <29719099+gitburd@users.noreply.github.com>
Co-authored-by: Naomi Quinones <52065567+naomiquinones@users.noreply.github.com>
2020-08-17 14:56:13 -07:00
Alex Aubuchon
3abb98124e
[actions] Add shellcheck workflow
Co-authored-by: Alex Aubuchon <alex@aub.dev>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2020-11-18 12:49:28 -05:00
Matteo De Wint
21c0c05130 [Fix] nvm_die_on_prefix: only grep lines starting with env var name 2020-11-16 11:35:26 +01:00
Alex Aubuchon
00af6341f7
[Tests] Run fast test suite in clean environment 2020-11-03 19:05:34 -05:00
Jordan Harband
11a9d22607
[actions] add "Allow Edits" workflow 2020-11-06 23:56:55 -08:00
Jordan Harband
bbe032fa7e
[actions] switch Automatic Rebase workflow to pull_request_target event 2020-11-06 23:55:52 -08:00
Jordan Harband
4054bd70ce
v0.37.0 2020-11-06 10:11:29 -08:00
Jordan Harband
499d303746
[Perf] use/nvm_die_on_prefix: replicate npm config algorithm and remove npm config call 2020-08-24 22:44:25 -07:00
Peter Dave Hello
31bc0a13c2 [Dockerfile] Clean up dated comment 2020-11-03 17:19:03 +08:00
Dena Burd
c72f2c6f21
[Fix] nvm ls-remote: accept versions that end with a dot
Fixes #983.
2020-09-24 13:46:29 -07:00
Alex Aubuchon
f2c5ce459a
[Tests] Fix nvm unload fast test cleanup 2020-10-22 20:43:36 -07:00
Jordan Harband
0f0d5e8270
[dev deps] alphabetize dependencies 2020-10-22 20:41:45 -07:00
Alex Aubuchon
e77ed07ccc
[Tests] Fix nvm_ls_current fast test 2020-10-13 12:32:41 -04:00
Dylan Armstrong
e01060fa2c
[Fix] nvm_die_on_prefix: use directory comparison rather than string 2020-10-09 09:43:21 -05:00
Dylan Armstrong
96069da0d5
[Fix] nvm_ls: zsh: unset markdirs and local_options
Fixes #2315.
2020-10-09 09:43:21 -05:00
Peter Dave Hello
4436638816
[Tests] Drop deprecated sudo: option in TravisCI config
That config was deprecated for a while, reference:
- https://blog.travis-ci.com/2018-10-04-combining-linux-infrastructures
2020-09-21 20:28:09 +08:00
Matthieu Bosquet
344cc32ac3
[readme] bash shell integration: Amended example to call cd when booting a terminal (previously only called on cd).
It means that works with for example VS Code's integrated terminal.
2020-10-05 17:30:03 +01:00
Jordan Harband
7929190e6e
[Docs] improve nvm --help output
Fixes #2301
2020-10-02 22:22:12 -07:00
Jordan Harband
8debf39f24
v0.36.0 2020-09-23 16:18:37 -07:00
Jordan Harband
c7ca08d575
[Fix] latest-npm: ensure npm 7 is not installed on node < 10 2020-09-23 14:50:33 -07:00
Peter Dave Hello
6110d31969
[dockerfile] Add missing apt pacakge locales
locale-gen command seems missing since uncertain point for a while:

```
Step 15/33 : RUN locale-gen en_US.UTF-8
 ---> Running in fae073c89c01
 /bin/bash: locale-gen: command not found
 The command '/bin/bash -o pipefail -c locale-gen en_US.UTF-8' returned
 a non-zero code: 127
```

This patch should fix the Docker image build
2020-09-21 18:20:50 +08:00
Peter Dave Hello
68d2f47c0a
[dockerfile] Update ShellCheck download URL in Dockerfile
see koalaman/shellcheck#1871
2020-09-21 09:36:30 +08:00
Jordan Harband
6e0562ac6d
[Tests] pin postcss to v7 2020-09-21 15:40:41 -07:00
Peter Dave Hello
68d331a816
[dockerfile] Remove ShellCheck Segmentation fault workaround
The workaround came from this GitHub issue comment:
https://github.com/koalaman/shellcheck/issues/1053#issuecomment-357816927

Looks like the problem doesn't exist any more:

```
.
.
.
Step 14/33 : RUN shellcheck -V
 ---> Running in 4b7a718c1cbf
ShellCheck - shell script analysis tool
version: 0.7.0
license: GNU General Public License, version 3
website: https://www.shellcheck.net
.
.
.
```

The workaround should be removed so that the Dockerfile will be easier
to be understand and read.
2020-09-21 02:47:57 +08:00
Saikat Das
22e07cc0c1
[readme] fix LTS upgrade command
Edited the LTS upgrade scenario command to fix the issue discussed in #2271
2020-08-27 19:27:29 +05:30
Jordan Harband
cf92956e5d
[New] add nvm_find_project_dir helper 2020-08-23 14:40:42 -07:00
Jordan Harband
1d88ecfce5
[Fix] nvm_die_on_prefix: check that the prefix is inside the version dir, not just the nvm dir
- also pass the version dir as the third argument
2020-08-23 22:50:41 -07:00
Jordan Harband
035bf9e28e
[readme] update autocompletion output examples 2020-08-23 23:29:48 -07:00
Michael Potter
f7fbad2bd6
[performance] nvm_auto: only call nvm_ls_current in use mode 2020-08-19 11:40:45 -07:00
Steve Lee
19c55b9936
[readme] Mention problem with windows cmd echo 2020-08-11 18:39:32 +01:00
Jordan Harband
9dc6f3e4a5
[Refactor] nvm run/nvm exec: use NVM_SILENT consistently internally 2020-08-13 14:37:41 -07:00
Jordan Harband
1c00753fd9
[New] nvm deactivate/nvm which: add --silent 2020-08-13 13:40:32 -07:00
Yash-Singh1
b1200c659b
[Fix] nvm use: fix --silent when version is omitted
Fixed a bug where --silent mode was failing for nvm use I ran a test
 that just ran ```nvm use node --silent``` that I wrote by myself.
 Unfortunately I noticed a bug where it still prints out some messages in
 different cases. This pull request is to fix that bug. * Added in an argument
 called ***quiet***  to the nvm_rc_version() function at *line 339* * Printed
 anything inside the nvm_rc_version() only in the scenario where quiet mode is
 off * Ran the nvm_rc_version() function in quiet mode only if silent mode is
 on in the "use" command of nvm at *line 2990* * Ran *nvm_echo* and *nvm_err*
 inside the "use" command of nvm only in the scenario where silent mode is off
 (There were 4 scenarios where this was forgotten) * Edited the ```nvm
 deactivate``` command to include a silent mode * Changed the help page to
 include the --silent option for ```nvm deactivate``` * Added in aliases for
 the --silent flag in ```nvm deactivate``` and ```nvm use``` * Used silent
 mode inside the ```nvm use``` when running ```nvm deactivate``` inside it and
 silent mode is on A test was attached in the 'test/slow/nvm use' directory.
 It is named *Running "nvm use node --silent" doesn't print anything*. It runs
 ```nvm use node --silent and checks``` and succeeds if the OUTPUT matches the
 EXPECTED_OUTPUT which is *null*  or *''*. When the test was run locally, it
 still ouputed results if someone deleted some contents of the *.nvm/* folder.
 This output was given from the ```nvm deactivate command```. This was the
 reason that the ```nvm deactivate``` was edited to include silent mode.
2020-08-08 17:27:46 -07:00
Jordan Harband
16b75b7333
[Robustness] add command to xargs/rm in nvm_get_default_packages
Fixes #2281.
2020-08-11 10:16:42 -07:00
Naomi Quinones
1bf567bd0b
[Fix] ensure --help is intercepted on any command
Co-authored-by: Naomi Quinones <52065567+naomiquinones@users.noreply.github.com>
Co-authored-by: Dena Burd <me@Denas-MacBook-Air.local>
2020-08-04 16:32:19 -07:00
Dimitris Karagiannis
a01deb11dc
[patch] Update docs and add warning for 'nvm is not compatible with the npm config "prefix" option' edgecase error on Mac OS 2020-08-03 10:04:20 -07:00
Kayla Altepeter
a5aec107df
[New] adding default and alias option to nvm install
For: `nvm install 8.12.0` after install:

--alias=8 is equivalent to `nvm alias 8 8.12.0`
--default is equivalent to `nvm alias default 8.12.0`

Co-authored-by: Kayla Altepeter <kayla@kaylaaltepeter.com>
Co-authored-by: Dena Burd <me@Denas-MacBook-Air.local>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2018-10-22 08:32:29 -05:00
Saikat Das
18c6f98acc
[readme] Add documentation for LTS updates which reinstall existing packages
Added an example for LTS updates that also reinstall the existing packages.
This is useful for individuals who run the latest LTS version along with global packages and need to update when the LTS version gets bumped
2020-07-28 19:31:30 +05:30
Jordan Harband
424aeb38b4
[Refactor] add nvm_get_checksum_binary; use it in nvm debug 2020-07-31 22:13:21 -07:00
Jordan Harband
abfe0a5891
[Refactor] remove unused nvm_checksum function 2020-07-31 22:10:28 -07:00
Naomi Quinones
3561bbc54a
[Fix] --help: Add more examples
Fixes #2120.
2020-07-28 17:56:48 -07:00
Jordan Harband
83043c4d3a
[debug] add whoami output 2020-07-25 13:38:52 -07:00
Dena Burd
55eafcd814
[New] add nvm -v as an alias for nvm --version
Fixes #2200.
2020-07-27 10:26:35 -07:00
ritmos
06c3bf6a8f
[Docs] --help: explain more clearly that <version> parameter is optional and can be provided by .nvmrc on nvm install, nvm use, nvm exec, and nvm run. 2020-06-20 15:15:01 +02:00
DeeDeeG
4b1100e515
[New] nvm_supports_xz: Add Mac/FreeBSD xz platform support checks
macOS only supports extracting xz tarballs with `tar` in 10.9 and up.

GNU tar needs an `xz` executable on the `PATH` to extract xz tarballs.

(These are the most common variants of tar, so until further testing
is done, conservatively assume all variants of tar (other than the one
shipped with macOS) need an xz executable on the PATH in order to
decompress xz tarballs.)

Fixes #2155.
2020-01-29 16:20:15 -05:00
Bram Wubs
f6d11bae41
[readme] Fix fish load_nvm function 2020-07-07 08:29:00 +02:00
Marcus Kazmierczak
d2d232ea2b
[readme] Update macOS troubleshooting w/ 10.15 zsh default
The default shell for macOS 10.15 is now zsh, by default a .zshrc file
is not created, so switch instruction for touch ~/.zshrc
2020-06-24 11:02:01 -07:00
Connor Leech
7b3af45cf7
[readme] Update install instructions troubleshooting
This is in response to a popular stack overflow answer that has helped people resolve the "command not found" hiccup: https://stackoverflow.com/a/17707224/2031033

Also mentioned here: https://github.com/nvm-sh/nvm/issues/748
2020-05-25 07:36:40 -07:00
Peter Dave Hello
bac5393e12
[Docs] Syntax highlight for Ansible task example in README.md 2020-05-29 21:01:47 +08:00
Szymon Dzialowski
2d4e877b61
[readme] Stop removing spaces from nvm_path
It breaks switching version of node through nvm in directories with space somewhere in it's path.
2020-06-10 18:28:14 +01:00
Jordan Harband
6575b6b052
[Fix] install: improved arg parsing around --reinstall-packages-from
Fixes #1762
2020-06-04 16:15:39 -07:00
Bruce A. MacNaughton
33fa27dabe
[Docs] Update README for environment variables 2020-02-07 12:01:57 -08:00
Sehrope Sarkuni
91a55dd91a
[Refactor] Rename solaris and iojs helper functions to be nvm_ prefixed
Renames node_version_has_solaris_binary and nvm_iojs_version_has_solaris_binary
to be prefixed with nvm_ so they do not show up in tab completion following the
word "node".
2020-05-08 16:08:27 -04:00
Jordan Harband
7aba64a2d5
[meta] further TOC action tweaks 2020-04-29 20:18:40 -07:00
Jared Ramirez
dcc8059ef8
[readme] include deeper integration instructions for fish 2020-04-29 15:25:23 -07:00
Jordan Harband
8e1e5df059
[meta] fix TOC action 2020-04-29 15:13:30 -07:00
Jordan Harband
e0ed1eacfd
[meta] add actions: Automatic Rebase for PRs, auto-update-TOC for push 2020-04-29 12:06:01 -07:00
Peter Dave Hello
73438e339e
Update Dockerfile base image to Ubuntu 16.04, cc #2008 2020-03-30 02:17:28 +08:00
Magnus Markling
b02617028f
[Tests] Source nvm.sh before defining FILE 2020-03-19 12:13:29 +01:00
Jordan Harband
f607f2f783
[Fix] reinstall-packages: do not include unmet peer deps
Closes #1948.
2020-03-10 23:51:17 -07:00
Jordan Harband
258938ef66
v0.35.3 2020-03-05 23:13:56 -08:00
Jordan Harband
096ba0d8c3
uninstall: add NVM_DEBUG to print out a filename as its permissions are checked 2020-03-05 17:40:17 -08:00
Jordan Harband
4626d1aae6
[New] add lts/-1 etc, to point to an LTS line relative to "latest" 2020-03-04 01:03:36 -08:00
Jordan Harband
c372ff03e0
[Tests] update mocks 2020-03-04 00:44:35 -08:00
Jordan Harband
30cd9c5dc8
[Tests] fix update mocks script 2020-03-04 00:57:58 -08:00
Jordan Harband
b9536327ae
[Fix] nvm ls-remote: properly label latest LTS versions instead of just the latest one in the filter
Fixes #2166
2020-02-21 21:27:13 -08:00
Jordan Harband
e609091a55
[Tests] update test mocks 2020-02-22 09:06:59 -08:00
flip111
8093dbeacd
[readme] add nvm intro
Closes #2149.
2020-01-23 20:32:07 +01:00
Jordan Harband
4cd6b4822c
[Tests] try to make nvm unload test more robust 2020-02-09 06:41:52 -10:00
Bruce A. MacNaughton
6c560b12b6
[New] use: set NVM_INC to expose the node include path 2020-02-07 06:23:35 -08:00
Jordan Harband
f4eddb2c9c
[Tests] ensure nvm unload unsets env vars too 2020-02-07 09:16:55 -10:00
Jordan Harband
a1ad32e9cb
[readme] restore broken anchor 2020-01-11 18:15:20 -08:00
nebbles
d8785da988
[Docs] Improve readme clarity and troubleshooting
Clean up readme structure a bit to help with readability. fix
instructions which could lead to a sourcing loop if misinterpreted.
guidance should direct macos users to simply copy the source snippet
manually into their desired profile file.

Resolve #2123
2019-11-17 14:52:52 +00:00
Lucian Buzzo
4ff9084e99
[Docs] Fix small typo in README 2019-12-05 10:07:38 +00:00
Jordan Harband
f355b327d6
v0.35.2 2019-12-17 22:40:20 -08:00
Jordan Harband
6fa92c82ca
[Fix] if a prefix env var is set (as in npm run), but is correct, do not fail
Fixes #2106.
2019-12-15 23:39:32 -08:00
Jordan Harband
0899839b95
[Tests] pin david to v11
v11.1.0 and v12 no longer work on node 0.10; v11.1.1 should.

See https://github.com/alanshaw/david/issues/159
2019-12-09 08:51:46 -08:00
Jordan Harband
73a513c389
[Fix] allow nvm unalias x when x is a default alias, but shadowed
Fixes #2122.
2019-11-12 11:16:08 -08:00
awthwathje
04ad1b528c
[readme] Fix a typo 2019-11-08 10:24:16 +01:00
Jordan Harband
1c8e59130f [meta] create FUNDING.yml 2019-11-05 12:05:09 -08:00
Jordan Harband
28bc2fd991
v0.35.1 2019-11-03 10:03:31 -08:00
Jordan Harband
100861d529
[Fix] install-latest-npm: npm v6.10 breaks on node v6.0, v6.1, and v9.0-v9.2 2019-11-02 20:53:18 -07:00
Marit Iren
1eca354233
[Docs] Add description if instructions don't work; make install instructions more readable 2019-10-20 17:08:29 +02:00
Guido Bouman
0a4e6f2b70
[meta] Update ISSUE_TEMPLATE.md
Remove the need to indent terminal output by using headings instead of a list.
Simplify formulation of steps
2019-10-08 15:27:53 +02:00
Jordan Harband
94a72ae217
[Fix] nvm use: improve help output with bare nvm use and no .nvmrc
Closes #1914.
2019-10-08 14:40:17 -07:00
Jordan Harband
011810e721
v0.35.0 2019-10-02 00:05:28 -04:00
Darío Hereñú
d48abff659
[Docs] clean up formatting in readme 2019-05-03 19:44:21 -03:00
Darío Hereñú
82037b41b1
[Docs] clean up a bit 2017-10-06 01:54:07 -03:00
Roman Isko
7b0a46eafb
[docker] add libssl-dev to Docker image 2018-06-18 10:33:12 +03:00
Roman Isko
dcbecbf2c7
[shellcheck] install shellcheck v0.6.0 in Dockerfile 2018-06-14 10:45:01 +03:00
metasean
970cadf258
[Docs] Add --latest-npm info to Migrating global packages section
Adds the following information to the "Migrating global packages while installing" section:
- notification that the npm package is explicitly not updated when using the --reinstall-packages-from flag
- information about the --latest-npm flag
- recovery instructions if a user has already updated node with an incompatible npm version
2018-12-30 18:24:29 -07:00
Will Papper
3cc9525dce
[Docs] [Fix] Set $NVM_DIR to ".nvm" instead of "nvm"
- Operating system and version: Mac OS X Mojave

- What happened? $NVM_DIR was set to nvm

- What did you expect to happen? $NVM_DIR should be set to .nvm
I added the following line from the README to my .zshrc:
```
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
```

I couldn't figure out why nvm wasn't loading, until I realized that
`echo NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"` outputs `NVM_DIR=nvm`.

Changing the line to `export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/}.nvm"` fixed the problem. This outputs `NVM_DIR=.nvm` as expected. I tested this and the same behavior holds true in Bash as well.
2019-04-24 00:03:01 -07:00
Greg Smith
6537c91eb5
Fix bash auto-use nvm command
It was trying to read ./.nvmrc if you cd'ed into a subdirectory of the directory that has .nvmrc, which would give print `-bash: ./.nvmrc: No such file or directory` to stderr and potentially not doing the `nvm install`.
2019-08-09 14:38:37 -06:00
Jordan Harband
07b20d5008
[meta] add copyright line to license file 2019-07-17 10:48:23 -07:00
Sehrope Sarkuni
0b5bb5ccd8
[Fix] set -u: Add default empty value for $NVM_NO_ALIAS
Adds a default value for NVM_NO_ALIAS so that nvm ls does not error out when run
in a bash nounset/-u (no unset vars) environment.
2019-05-14 08:31:24 -04:00
Bastian Fuchs
45c1b84794
[Fix] Determine correct sub directory if XDG_CONFIG_HOME is set
With the environment variable XDG_CONFIG_HOME set, the installation
script uses the directory $XDG_CONFIG_HOME/nvm now. Before the change
the variable's value with "/nvm" cut off was used, which usually results
in an installation without any subdirectory.
2019-04-28 12:51:15 +02:00
Alfred Myers
3664744e3b
Updated note about Windows
There's a lot of old info around the interwebs.
Much stating nvm doesn't work in WSL.
2019-05-02 12:20:17 -03:00
Jordan Harband
ee9e56582e
[Tests] jspm v2 beta started breaking tests; pin to < v2 2019-05-04 13:34:16 -07:00
Jordan Harband
e7a5b7992b
[meta] update repo links to point to org 2019-04-24 16:08:34 -07:00
Daniel Li
ff77ac17af
[Docs] update bash cdnvm script to properly handle aliases
- Only works for common aliases like `default`, `system`, `node`, `lts/*`, `iojs` etc.
 - Prevent unnecessary running of `nvm use`
2019-03-12 16:43:08 +00:00
Christopher Sahnwaldt
2410215b6a
[Refactor] add nvm_stdout_is_terminal helper 2019-02-24 00:03:19 +01:00
Christopher Sahnwaldt
a1abfd1fe4
[Tests] use rimraf over rmdir in teardowns
- fix test 'Running "nvm ls" should display all installed versions.': only expect versions created by this test, but no versions created by other tests
2019-02-27 10:50:59 +01:00
Jordan Harband
43402df896
[Fix] nvm_supports_source_options: work around a bug in bash 3.2
See https://github.com/creationix/nvm/issues/1978#issuecomment-453480231

Fixes #1978.
2019-02-26 16:53:36 -08:00
Eric Lewis
1ede50cbae
[Docs] Add note about what version of node new shells run with.
Fixes #2000
2019-02-22 10:04:13 -05:00
Jordan Harband
e0d87528f3
[shellcheck] remove unnecessary overrides 2019-02-24 23:04:13 -08:00
Refael Ackermann
924a175bd8
[Tests] update dist from trusty to xenial 2019-02-25 15:02:15 -05:00
Jordan Harband
9daf26f0a0
[Tests] nvm_command_info: make error output more helpful 2019-02-25 13:17:10 -08:00
Jordan Harband
226487d358
[Fix] install: error out when an argument has ---
Fixes #1915.
2019-02-25 00:13:50 -08:00
Jordan Harband
216c24fba0
[Docs] --help: consolidate some help output 2019-02-24 22:57:06 -08:00
Christopher Sahnwaldt
930507dbbc
[Docs] README.md: mention --no-colors option 2019-02-23 09:53:56 +01:00
Jordan Harband
4c8ced736d
[Docs] nvm --help: add --no-colors and --no-alias 2019-02-24 00:04:40 -08:00
Jarvis Mercer - Amir Mohammad Safari (AMSL)
1f7f0c2d81
[Docs] add version number to nvm —help output 2019-01-27 04:13:12 +03:30
Jarvis Mercer - Amir Mohammad Safari (AMSL)
41eb40821b
[Docs] add “update” terminology to installation section 2019-01-26 01:00:43 +03:30
Jordan Harband
c6740f5a6e
[New] nvm ls: add --no-alias to suppress alias output
Per https://github.com/creationix/nvm/issues/1792#issuecomment-466696504
2019-02-23 22:41:46 -08:00
Jordan Harband
04fdb2331b
[Tests] nvm ls: ensure nvm alias is called 2019-02-23 22:22:18 -08:00
Jordan Harband
58d0933f72
[Fix] attempt to fix a bug in bash 3.2, fixed in 4.4, that improperly exits on -e in a test.
See https://gist.github.com/ljharb/6e70a79ac5fcf11a8b9de654a88642aa for details.
2019-02-23 22:21:46 -08:00
Jordan Harband
2a5d2c06ff
[Tests] add more checks to make_fake_* helpers 2019-02-23 15:24:02 -08:00
Jordan Harband
2a513a1bc0
[Fix] nvm_ls: Reverts #1462 to fix io.js sorting.
<details>
<summary>Before this revert:</summary>

```sh
iojs-v3.3.1
iojs-v2.5.0
v0.6.21
v0.7.12
iojs-v1.8.4
v0.8.28
v0.9.12
v0.10.48
v0.11.16
v0.12.9
v0.12.18
v0.12.87
v4.9.1
v5.11.1
v5.12.0
v6.14.4
v6.16.0
v7.10.1
v8.6.0
v8.9.1
v8.10.0
v8.11.3
v8.11.4
v8.12.0
v8.13.0
v8.14.1
v8.15.0
v9.11.2
v10.0.0
v10.1.0
v10.2.1
v10.3.0
v10.4.1
v10.5.0
v10.6.0
v10.7.0
v10.8.0
v10.9.0
v10.10.0
v10.11.0
v10.12.0
v10.13.0
v10.14.2
v10.15.1
v11.0.0
v11.1.0
v11.2.0
v11.3.0
v11.4.0
v11.5.0
v11.6.0
v11.7.0
v11.8.0
v11.9.0
v11.10.0
```
</details>

<details>
<summary>After this revert:</summary>

```sh
v0.6.21
v0.7.12
v0.8.28
v0.9.12
v0.10.48
v0.11.16
v0.12.9
v0.12.18
v0.12.87
iojs-v1.8.4
iojs-v2.5.0
iojs-v3.3.1
v4.9.1
v5.11.1
v5.12.0
v6.14.4
v6.16.0
v7.10.1
v8.6.0
v8.9.1
v8.10.0
v8.11.3
v8.11.4
v8.12.0
v8.13.0
v8.14.1
v8.15.0
v9.11.2
v10.0.0
v10.1.0
v10.2.1
v10.3.0
v10.4.1
v10.5.0
v10.6.0
v10.7.0
v10.8.0
v10.9.0
v10.10.0
v10.11.0
v10.12.0
v10.13.0
v10.14.2
v10.15.1
v11.0.0
v11.1.0
v11.2.0
v11.3.0
v11.4.0
v11.5.0
v11.6.0
v11.7.0
v11.8.0
v11.9.0
v11.10.0
```
</details>

In other words, the sorting needs to happen *before* the `NVM_NODE_PREFIX` is removed.
2019-02-23 15:02:31 -08:00
Jordan Harband
48196d2436
[Tests] fix fake node versions 2019-02-23 14:47:49 -08:00
Jordan Harband
7f9220dbd8
[Fix] nvm ls: --no-colors: system: print an asterisk 2019-02-23 14:41:57 -08:00
jjangga0214
890fbb5581
Update README: sync node release schedule url 2019-02-15 11:11:01 +09:00
Jordan Harband
e1bb44f712
[shellcheck] add overrides 2019-02-04 14:45:04 -08:00
Jordan Harband
db19450caa
[Fix] default_packages: work when the file lacks a trailing newline
Fixes #1995.
2019-02-02 13:45:11 -08:00
Jordan Harband
5c117e6ab3
[Refactor] extract “get default packages” logic to nvm_get_default_packages 2019-02-01 13:27:18 -08:00
Lucas Kellner
02997b0753
[Docs] unalias: add more specific error message for builtin aliases 2019-01-23 16:39:57 -08:00
Peter Dave Hello
cc0750eb5d
[Fix] install: Add missing io.js installation message
Fixes #1988
2019-01-22 15:46:29 +08:00
Peter Dave Hello
7e715d5c73
[Tests] Improve syntax in "test/installation_iojs/nvm install v1 works" 2019-01-23 03:10:03 +08:00
Jordan Harband
66d2909650
Merge pull request #1986 from Sayegh7/master
[Fix] Make installation less restrictive when NVM_DIR is set
2019-01-22 10:50:10 -08:00
Jordan Harband
a56c6f1485
tweak logic 2019-01-21 21:58:43 -08:00
Ahmed El Sayegh
703babe60a
[Fix] Make installation less restrictive when NVM_DIR is set 2019-01-21 02:15:02 +02:00
Peter Dave Hello
10f24d6d4b
[Refactor] nvm.sh: make coding style more consistent 2018-05-22 20:57:40 +08:00
Peter Dave Hello
e367533eb8
[Refactor] Reduce one more sed & pipe to speedup 2017-03-28 23:15:35 +08:00
Peter Dave Hello
6534568745 [Fix] Enhance nvm debug for different environments 2019-01-12 14:17:01 +08:00
Waldir Pimenta
13f3cdcdf7
README: clarify how to specify default packages 2019-01-11 10:42:33 +00:00
Jordan Harband
3d9c31d944
v0.34.0 2019-01-07 23:01:16 -08:00
Jordan Harband
0acccb8a77
Merge pull request #1974 from valeriemettler/valeriemettler-patch-1
[Docs] Improve phrasing of 'nvm current'
2019-01-05 14:10:31 -08:00
Valerie Mettler
6354b170d7
Improve phrasing of 'nvm current'
To help beginners know that 'nvm current' is talking about node and not nvm.
2019-01-05 12:20:56 -08:00
Javier Infante
5e065ec026 [Docs] fixing cdnvm on .bashrc 2018-12-31 08:42:58 +01:00
Peter Dave Hello
206d503a21
[Docs] Improve indent of output block in GitHub Issue template 2018-12-26 03:46:13 +08:00
Jordan Harband
deb2a9b821
[Docs] fix eclint 2018-12-19 15:36:24 -08:00
Joel Parker Henderson
fb83eeb140
[Docs] Add Ansible task example
Add Ansible task example to show how to install nvm and update it.

Ansible is a systems administration tool.
See https://github.com/ansible/ansible

My personal experience of `nvm` is that installing via Ansible is good, and that a good example can help. This example took me about an hour to learn, so I'm hoping to save other people some time. This example is somewhat different than any others that I found on the web. There may be a better way to write it, and if so, please improve it.
2018-12-19 12:45:59 -08:00
Peter Dave Hello
14179bc8ce
[shellcheck] Use -n/-z instead of ! -z/! -n condition
https://github.com/koalaman/shellcheck/wiki/SC2236
2018-12-03 13:59:19 +08:00
Jordan Harband
153506c8da
[shellcheck] ignore SC2230 errors 2018-11-25 16:22:25 -08:00
Jordan Harband
c1150c41ab
[Tests] avoid using shopt in zsh 2018-11-26 11:18:11 -08:00
Jordan Harband
ad1110ef1a
[Tests] print out shellcheck version 2018-11-25 23:56:19 -08:00
Jordan Harband
914c220586
Merge pull request #1947 from PeterDaveHello/Enable-ccache-on-TravisCI
[Tests] Enable ccache on Travis CI to speed up compilation
2018-11-24 23:18:23 -06:00
Peter Dave Hello
22d32bede0 [New] Enable ccache on Travis CI to speed up compilation 2018-11-22 13:58:26 +08:00
Jordan Harband
a49d9163ef
[Fix] avoid unbound variable
Fixes #1949.
2018-11-21 21:25:20 -06:00
Alexander Groß
17586b971a
[Fix] Allow zsh users to have the nomatch option set
Closes #1937.
2018-11-08 00:55:52 +01:00
Peter Dave Hello
f3fd5eff46
[Docs] Improve md file syntax
- Lists should be surrounded by blank lines
- Use only `1.` for ordered list item prefix
- Starting bulleted lists at the beginning of the line
- Fenced code blocks should be surrounded by blank lines
2018-07-15 02:26:05 +08:00
Kayla Altepeter
423252a99c
[docs] update README to fix docker run command flag order 2018-10-18 22:30:05 -05:00
Ole Johan Andersen
2a294ebd61
[Docs] improve instructions for manual install 2018-10-24 19:49:55 +02:00
Jordan Harband
a08d1ea4a3
Merge pull request #1865 from d4nyll/master
[Docs] Add section on automatic `nvm use` in Bash

Replaces #1108 and #1677. Closes #1678.
2018-11-05 16:10:15 -08:00
Fábio Antunes
217a5bb0de
[Docs] Added fish nvm 2018-10-21 23:31:20 -07:00
Paul Nickerson
caf6208dbd
install.sh: Print an error and exit the script if $METHOD is set to something unexpected. 2018-10-02 13:46:26 -04:00
Nathan Burchill
0c2efed407
[New] bash_completion: Add support for ZSH_DISABLE_COMPFIX flag.
When using Oh My Zsh the ZSH_DISABLE_COMPFIX flag allows the zsh completion system to use files it deems to be insecure.
2018-09-18 16:15:35 -04:00
et304383
2d97ce5f7b
[Docs] add instructions for installing a specific version 2018-08-27 11:50:48 -03:00
Erik Lilja
8542df4ac5
[New] add support for $XDG_CONFIG_HOME 2018-08-14 21:45:40 +02:00
Jordan Harband
f218a85454
[Tests] eslint 5.5+ seems to not install on node 0.10 2018-09-09 14:56:17 -07:00
Jordan Harband
96ebed37c7
Merge pull request #1863 from PeterDaveHello/ImproveDockerfile
Improve Dockerfile
2018-08-23 09:13:47 -07:00
Jordan Harband
e7a37f336d
[Tests] fix failing tests on master due to npm registry SSL changes 2018-08-15 15:01:47 -07:00
Daniel Li
e06f735776
Improve Bash alias
This will take into account nested directories inside your main project
directory
2018-07-26 16:13:07 +01:00
Daniel Li
355c4c7915
[Docs] Add section on automatic nvm use in Bash 2018-07-15 19:08:15 +01:00
Peter Dave Hello
4bd99bcfa2 [Dockerfile] Refactor to prevent using sudo during build
`sudo` may lead to unpredictable behavior in some cases, and we don't
really need to use `sudo` to reach what we need.
2018-07-12 18:38:15 +08:00
Peter Dave Hello
5f9ccaada0 [Dockerfile] Set the SHELL to bash with pipefail option 2018-07-12 18:38:15 +08:00
Peter Dave Hello
7ff20855a2 [Tests] Integrate dockerfile_lint to test Dockerfile 2018-07-12 18:38:14 +08:00
Peter Dave Hello
cdde74a55d [Dockerfile] install missing eclint package 2018-07-12 18:37:40 +08:00
Jordan Harband
17c33fd9ae
Merge pull request #1861 from PeterDaveHello/ImproveDockerfile
Improve and update Dockerfile
2018-07-11 12:15:25 -07:00
Peter Dave Hello
04b35b5440 [Dockerfile] Use arguments JSON notation for ENTRYPOINT 2018-07-11 15:17:27 +08:00
Peter Dave Hello
aacb0b9b97 [Dockerfile] Fix command From to be FROM 2018-07-11 15:17:27 +08:00
Peter Dave Hello
f121e5ace0 [Dockerfile] Add missing quotes for variables 2018-07-11 15:17:18 +08:00
Peter Dave Hello
af8038ffec [Dockerfile] Update ShellCheck version to v0.5.0 2018-07-11 15:14:00 +08:00
Peter Dave Hello
265ec90532 [Dockerfile] Add missing name & version LABEL 2018-07-11 15:14:00 +08:00
Peter Dave Hello
e2195b4c35 [Dockerfile] Use LABEL instead of deprecated MAINTAINER command 2018-07-11 15:13:57 +08:00
JBallin
41dc4218b9 [Docs] add --no-use option to installation 2018-06-17 21:31:56 -07:00
Xandor Schiefer
90cfb5d771
[Fix] use: Prepend instead of changing if shadowed by system dirs (fixes #1652) 2018-06-08 15:23:02 +02:00
Joshua Li
0cdc184168
[Fix] Improve nvm_is_version_installed to check for a node executable instead of root dir 2018-05-31 15:26:30 -07:00
Joshua Li
a5f42d9cea
[Tests] update most mkdirs to use make_fake_{node,iojs} 2018-06-13 10:38:19 -07:00
Xandor Schiefer
eabd7ab13d
Respect previously nvm-loaded node version when sourcing 2016-11-14 19:18:24 +02:00
Jordan Harband
b111436fde
[Tests] test nvm install-latest-npm on io.js v2 2018-06-06 22:49:56 -07:00
Spike Grobstein
9854928ba9
[New] install.sh: allow user to explicitly opt out of nvm adding the source string
this is done by checking if the user supplies `PROFILE=/dev/null` when running `install.sh`, the `nvm_detect_profile` function will not output any strings, causing `nvm_do_install` to skip adding `SOURCE_STR`.
2018-05-03 08:22:07 -07:00
Jordan Harband
c50ea6f0a3
[shellcheck] quote variables in for loops to avoid unintentional expansion 2018-05-31 23:56:20 -07:00
Jordan Harband
628d4fac84
[shellcheck] use { …; } instead of (…) to group test commands 2018-05-31 23:49:15 -07:00
Jordan Harband
ef35bc4cb6
Merge pull request #1823 from SrHuevo/master
fix for .nvmrc script
2018-05-30 20:08:07 -04:00
SrHuevo
d08d8607f5
fix for .nvmrc script 2018-05-30 09:02:29 +02:00
Jay Williams
e7b53a01fd
Grammar update 2018-05-26 23:17:08 +01:00
Siddharth Sakhadeo
b81c120e0c fix failing if check in autoload script 2018-05-25 15:33:42 -07:00
Jordan Harband
57ec311f53
[Fix] ls-remote: fix issues in zsh when using a mirror with a ton of entries
Merge pull request #1818 from adedomin/master
2018-05-24 14:08:20 -04:00
Jordan Harband
38b32c27f3
[Tests] update mock data 2018-05-23 23:48:50 -04:00
adedomin
7a5ff0d133
[Fix] ls-remote: fix issues in zsh when using a mirror with a ton of entries
Fixes #1813
2018-05-23 19:47:11 -04:00
Jordan Harband
f5f029c409
[Fix] “unstable” alias: when there’s no “unstable” minors, output “N/A” 2018-05-24 12:23:02 -04:00
Jordan Harband
c465a83518
[Tests] nvm ls-remote: add test for overly-large tab file 2018-05-23 23:48:04 -04:00
Peter Dave Hello
62ee7cf998
[Refactor] bash_completion: Improve coding style 2018-05-21 19:59:01 +08:00
Peter Dave Hello
113d807e5a
[New] Support --no-progress for nvm install
Closes #1079.
2017-03-10 01:07:16 +08:00
Jordan Harband
3fc7b737f5
[Fix] install -s: zsh: ensure shwordsplit opt is set
Fixes #1719.
2018-04-29 15:35:39 -07:00
Josh Sleeper
04c27e23fe
add --tags to git fetch in manual upgrade
facilitates older `git` fetching tags so that it can actually upgrade properly
2018-04-25 14:55:31 -07:00
Jordan Harband
592c0be195
Merge tag 'v0.33.11'
v0.33.11

Fixes
 - `nvm install-latest-npm`: node v4.5 and v4.6 work on npm v5.4.1, but not v5.4.2
2018-04-25 13:26:19 -07:00
Jordan Harband
93990ab7da
v0.33.11 2018-04-25 13:25:35 -07:00
Jordan Harband
61c7b133f8
[Fix] nvm install-latest-npm: node v4.5 and v4.6 work on npm v5.4.1, but not v5.4.2 2018-04-25 13:25:28 -07:00
Jordan Harband
eb0a8442d8
[Fix] nvm install-latest-npm: node v4.5 and v4.6 work on npm v5.4.1, but not v5.4.2 2018-04-25 10:08:41 -07:00
Jordan Harband
a26ab88478
[Tests] fix nvm install-latest-npm tests to fail properly 2018-04-24 22:23:44 -07:00
Jordan Harband
1f2a3234d2
[Tests] add nvm install-latest-npm tests for all node versions 2018-04-24 22:23:44 -07:00
Jordan Harband
34e1ec800e
Merge tag 'v0.33.10'
v0.33.10

Fixes
 - `install-latest-npm`: npm 6 is out, and requires node 6 or higher
2018-04-24 22:09:27 -07:00
Jordan Harband
177a9673a7
v0.33.10 2018-04-24 22:08:51 -07:00
Jordan Harband
db98f8cdaf
[Fix] install-latest-npm: npm 6 is out, and requires node 6 or higher 2018-04-24 22:08:16 -07:00
Jordan Harband
c983fefbae
Merge pull request #1734 from PeterDaveHello/improve-NVM_DIR-handling
[Fix] Remove $NVM_DIR trailing slash automatically
2018-04-24 16:22:42 -07:00
Jordan Harband
42f11acce1
[Fix] install-latest-npm: npm 6 is out, and requires node 6 or higher 2018-04-24 14:39:46 -07:00
Jordan Harband
09f7bbb78c
[Refactor] use a different approach to remove trailing slashes 2018-04-24 13:24:08 -07:00
Peter Dave Hello
d5dacdf80f
[Fix] nvm debug: Fix sed syntax error in nvm_command_info() 2018-04-17 18:09:47 +08:00
Peter Dave Hello
d3a9272a0c [Refactor] Speedup nvm_list_aliases() 2018-04-18 17:03:47 +08:00
Jordan Harband
1b14e6b4d9
v0.33.9 2018-04-14 22:38:18 -07:00
Jordan Harband
f060867f15
Merge pull request #1739 from PeterDaveHello/add-editorconfig
[New] Add EditorConfig to help maintain part of coding style
2018-04-14 22:36:25 -07:00
Jordan Harband
0da699605e
[eclint] only check non-ignored files 2018-04-14 22:12:22 -07:00
Peter Dave Hello
d9dc8464fd
[Doc] Add macOS install script note about Git
Closes #1782
2018-04-13 01:14:39 +08:00
Peter Dave Hello
685312d600
[Fix] Remove $NVM_DIR trailing slash automatically, fix #1708 2018-04-12 14:14:58 +08:00
Peter Dave Hello
0731003cfe
[New] Integrate eclint to test partial coding style 2018-02-26 02:29:38 +08:00
Peter Dave Hello
ca66a13710
nvm debug: Improve OS version detection 2018-02-24 02:53:40 +08:00
Peter Dave Hello
8ff437ae51
[Doc] Fix manual install & upgrade guide, fix #1772 2018-04-12 23:58:30 +08:00
Peter Dave Hello
b15709e637 Turn off wget's output in nvm_get_latest()
curl output is turned off by `-s` in the same place, we should unify the
behavior on wget, also, this help removes those wget outputs that can't
fit our coding style tests. cc #1739
2018-04-12 23:44:27 +08:00
Brian M. Jemilo II
8b71861d06
[Fix] install.sh: Detect profile with $BASH_VERSION and $ZSH_VERSION
Using `$(basename "/$SHELL")` to detect the shell would also choose bash on mac
2018-04-09 15:13:02 -05:00
Brian M. Jemilo II
68fe26a5e4
[Fix] Add autocompletion support to zsh
Fixes #1707.
2018-04-09 14:54:28 -05:00
Peter Dave Hello
37e0977e60
install.sh: Improve install.sh prompt output, add a newline 2018-04-10 15:53:33 +08:00
Jordan Harband
918a39a0d0
[Tests] update mocks 2018-04-09 23:29:37 -07:00
Jordan Harband
52f1b24895
[Tests] fix mirrors in mocks update script 2018-04-09 23:28:17 -07:00
Jordan Harband
74ff70aab3
[Fix] installing with an LTS name should lowercase the name before ensuring a default
Fixes #1781.
2018-04-09 23:23:27 -07:00
Ed Reel
663bddee9b
[docs] Add removal instructions to README.md
Closes #1767.
2018-04-09 10:36:54 -05:00
Guy Lepage
bc87d3dd1c
removed global install on README.md. closes #1773 2018-04-04 19:03:03 -04:00
easyaspi314 (Devin)
d8689f6b9a
bash_completion: Reduce startup time 2018-03-12 10:41:05 -04:00
Jordan Harband
0e3bb2cc47
[Fix] ensure --reinstall-packages-from has a version number.
Fixes #1760.
2018-03-14 00:13:07 -07:00
Peter Dave Hello
2850e65b62
[Docs] Fix some typos 2018-03-03 21:18:42 +08:00
Josh Soref
2859a19bbd
[Docs] fix spelling 2018-03-06 04:38:01 +00:00
Peter Dave Hello
d6fa67166c
[Fix] reinstall-packages: Prevent install/link when no packages found
Fixes #1744.
2018-02-27 14:05:33 +08:00
Peter Dave Hello
25b7f264d5 [Fix] Use nvm_echo instead of echo directly 2018-02-28 02:16:24 +08:00
Jordan Harband
5fc8bd950d
Fix whitespace 2018-02-25 13:34:28 -08:00
Peter Dave Hello
750571056c
[Fix] Correct most of the wrong indentation 2018-02-26 02:20:21 +08:00
Peter Dave Hello
544c3f4caa
[New] Add EditorConfig to help maintain part of coding style 2018-02-21 01:26:02 +08:00
Peter Dave Hello
e7b42198b4
[Fix] Improve .nvmrc reading process
Fixes #1015. Fixes #1712.
2018-02-20 03:34:43 +08:00
Peter Dave Hello
5f53caadad
[Refactor] Use grep -q parameter instead of redirect to /dev/null 2018-02-03 11:29:31 +08:00
Peter Dave Hello
9c42470347
[New] Add "$PATH" to nvm debug output 2018-02-06 08:17:20 +08:00
Peter Dave Hello
9f34b3e95c Remove trailing space 2018-02-26 01:03:01 +08:00
Peter Dave Hello
41ec44f6b5 Add missing final newline in test script 2018-02-26 01:02:41 +08:00
Peter Dave Hello
2cd2c0f72e Remove useless trailing newlines 2018-02-26 01:01:30 +08:00
Peter Dave Hello
f3076d14c9
[Fix] Add missing "command" prefixes for few commands 2018-02-20 04:05:47 +08:00
Peter Dave Hello
bb803492d8 Remove duplicate code in nvm_npm_global_modules()
No matter what's the result of the condition here, the path is the same.
2018-02-22 09:43:09 +08:00
Peter Dave Hello
f290ccf1d5
[Fix] Add missing "command" prefix for "tr", fix #1725 2018-02-19 13:59:26 +08:00
Peter Dave Hello
225e447b54 [Doc] Update Docker image build info in README.md 2018-02-19 00:27:04 +08:00
Peter Dave Hello
77da9f5a6d
Optimize ShellCheck installation in Docker image
Use pre-built static release binary instead of building ShellCheck from
the source code, this change would save disk space, time, and much
computing resources.
2018-01-18 00:33:41 +08:00
Peter Dave Hello
3ed47431f8
[New] Print $SHLVL in nvm debug 2017-11-05 03:25:04 +08:00
Peter Dave Hello
aad269d224
Display FreeBSD and SunOS with correct caps 2018-02-12 02:15:01 +08:00
Christoph Krautz
74f455e610 [Docs] Add reminder that NVM_DIR should not contain trailing slash, fix for #1708 2018-02-09 11:51:46 +01:00
Karthik K
f5b5f2d41d
[copyright] year to 2010 obsoleting future updations 2018-01-26 12:20:13 +05:30
Peter Dave Hello
a23f7169a6
[Fix] Correct nvm.sh indent 2018-01-26 11:30:57 +08:00
Jordan Harband
71032cfaa1
[Tests] update to latest npm in this test 2018-02-08 22:53:41 -08:00
Jordan Harband
6dd9ecb607
[Docs] add nvm which current to nvm --help output 2018-01-16 16:55:50 -08:00
Yannick Ihmels
7ca8acc98d
[Docs] [Tests] Add escape sequences; add test for aliased . 2018-01-13 21:25:30 +01:00
Paul Norman
d34bb3247d
install.sh: Don't give detached HEAD advice when installing 2018-01-10 13:21:27 -08:00
Jordan Harband
3e81904525
Update minimum git version to v1.17.10
Per https://github.com/creationix/nvm/pull/1704#discussion_r161366186
2018-01-12 23:24:56 -08:00
Jordan Harband
7cba6cd6d0
install.sh: detect a defined but nonexistent $NVM_DIR
(ref: #1700)
2018-01-06 09:34:11 -08:00
p-salido
9273f23bc8
[Docs] Explain .nvmrc better 2017-11-23 23:09:44 -05:00
Jordan Harband
2a259435c8
Merge pull request #1684 from PeterDaveHello/ShellCheck-v0.4.7-fixes
ShellCheck v0.4.7 fixes
2017-12-13 14:49:34 -08:00
Peter Dave Hello
2a8a81da94 [Fix] ShellCheck SC1117 in nvm.sh & install.sh 2017-12-14 03:26:17 +08:00
Peter Dave Hello
fce7f4ed13 [Fix] Disable ShellCheck SC2207 in bash_completion line 14 2017-12-14 02:11:50 +08:00
Jordan Harband
7ad6d98ced
v0.33.8 2017-12-12 10:43:17 -08:00
Jordan Harband
fa9c50520d [Fix] nvm install-latest-npm: fix for node 4.5/4.6. 2017-12-12 00:13:00 -08:00
Jordan Harband
4846d57c69
nvm use: perfect pre-npm-config env var checking 2017-12-05 00:00:18 -08:00
Jordan Harband
65f0572bdc
v0.33.7
Fixes
 - fix unassigned variable (#1665, #1664)
 - Fix for $path used by zsh (#1669)
 - `set -u`: ensure `NVM_USE_OUTPUT` is always set (#1671)
 - `install.sh`: Fix a bug that block that installation of node in install.sh (#1676)
 - `nvm install-latest-npm`: fix node 4-4.6

Documentation
 - Make `nvm cache clear` message less ambiguous (#1644)
 - Added missing piece (#1658)
2017-12-08 21:21:42 -08:00
Jordan Harband
b6a7a54d04
[Fix] nvm install-latest-npm: fix node 4-4.6 2017-12-08 21:20:59 -08:00
Jordan Harband
8a8dcbb393
Merge pull request #1676 from Quadric/fix-node-version-in-install-script
`install.sh`: Fix a bug that block that installation of node in install.sh
2017-12-03 11:47:39 -08:00
Ahmad Magdy
bacdd95591 Update test/install_script/nvm_install_with_node_version to use nvm ls 8 instead of grep! 2017-11-30 15:33:01 +01:00
Ahmad Magdy
4b0563093c Add test nvm_install_with_node_version under test/install_script 2017-11-30 15:23:37 +01:00
Ahmad Magdy
c7ac69bfbb Fix nvm_install_node function in install.sh script to not override the actual NODE_VERSION value 2017-11-30 14:47:42 +01:00
Jordan Harband
a57fe846e8
[Fix] set -u: ensure NVM_USE_OUTPUT is always set.
Fixes #1671.
2017-11-23 10:02:37 -06:00
Jordan Harband
7bfd1e0644
Merge pull request #1669 from mail6543210/master
Fix for $path used by zsh
2017-11-22 08:52:13 -08:00
mail6543210
9352f6913a Add symbolic link for printf in case of command-not-found 2017-11-22 02:01:38 +08:00
mail6543210
16d3e6d2dc Remove unnecessary, incorrect workaround.
The "\printf" calls zsh shell builtin instead of `command printf` in scripting.

The workaround is no longer needed given 91a29c0.
2017-11-22 00:57:27 +08:00
mail6543210
91a29c0da2 Fix for $path used by zsh
"The lower-case version of PATH is an array parameter
bound to the scalar upper-case parameter."
-- http://www.zsh.org/mla/users/2015/msg00178.html
2017-11-20 22:32:13 +08:00
Jordan Harband
4b48556e92
Merge pull request #1665 from norpol/fix_issue_1664_unassigned_variable_20171115
Fix #1664: unassigned variable
2017-11-17 23:31:26 -06:00
Phileas Lebada
be171bba33 Add unset-variable as exit error 2017-11-15 17:19:05 +01:00
Phileas Lebada
049a86022f Add empty value to local variable 2017-11-15 17:17:57 +01:00
David Gatti
a7b7eec0c5
[Docs] Added missing piece
This sentence broke my brain when I read it the first time :) I hope this helps.
2017-11-08 01:02:15 +01:00
Jordan Harband
9953a52afb
Merge pull request #1644 from citrusui/patch-1
[Docs] Make `nvm cache clear` message less ambiguous
2017-10-28 22:42:14 -07:00
Avery Magnotti
fc30e0ade4
Make nvm cache clear message less ambiguous 2017-10-28 20:30:28 -04:00
Jordan Harband
b546436113
v0.33.6 2017-10-23 23:53:26 -07:00
Darío Hereñú
016bc134d5 Typo 2017-10-23 02:23:04 -03:00
Peter Dave Hello
9c25a8f316 [Cleanup] Remove ghc related things in .travis.yml, cc #1619 2017-10-22 00:42:07 +08:00
Christopher Beland
a954458829
[Docs] Improve git installation instructions 2017-10-18 10:39:11 -04:00
Jordan Harband
09951b49c5 Only apps should have lockfiles 2017-10-05 13:34:54 -07:00
Jordan Harband
3b133fac2f
[Fix] install-latest-npm: npm v5.4+ breaks on node v4.5 and v4.6. 2017-10-04 11:04:27 -07:00
Michał Gołębiowski-Owczarek
6ac8ebafba Add a Git .mailmap with my new name
In this way my past contributions are mapped correctly.
2017-10-04 12:55:41 +02:00
Jordan Harband
62fb0d0ad6 Merge pull request #1605 from PeterDaveHello/fix-install.sh
[Fix] install.sh shouldn't use not existed variable
2017-10-03 22:23:48 -07:00
Peter Dave Hello
a461a0fffc [Fix] install.sh shouldn't use not existed $NVM_PROFILE 2017-10-04 10:10:47 +08:00
Jordan Harband
6597e11971
v0.33.5 2017-09-29 12:50:27 -04:00
Jordan Harband
707d268a76 Merge pull request #1619 from PeterDaveHello/refactor-travis-config
Remove the manual ShellCheck install proecss on Travis CI
2017-09-28 10:45:49 -07:00
Peter Dave Hello
73ad812215 Remove the manual ShellCheck install proecss on Travis CI 2017-09-29 00:22:43 +08:00
Jordan Harband
8c578b864d [Fix] ensure all grep calls go through nvm_grep.
Fixes #1615.
2017-09-22 19:11:43 -07:00
Peter Dave Hello
d535c97d0f Enhance nvm debug with more tools info 2017-09-21 22:09:15 +08:00
Xandor Schiefer
334897ae39
Preserve PATH locations order when changing versions 2016-11-14 19:19:39 +02:00
Jordan Harband
7b8af94fc9
[Tests] retry io.js test runs, since iojs.org is flaky. 2017-09-08 01:32:54 -07:00
Peter Dave Hello
7753b24948
[Docs] Update README.md for Alpine linux reference
Add 4 packages as Alpine Linux wiki suggested:
(grep util-linux binutils findutils)

https://wiki.alpinelinux.org/wiki/How_to_get_regular_stuff_working
2017-09-07 18:00:08 +08:00
Xandor Schiefer
44ab611421
[Fix] unset NVM_RC_VERSION when unloading 2017-09-07 16:52:05 +02:00
Jordan Harband
c0b56d03a1
[Fix] install-latest-npm: io.js v1.0.x has weird behavior with npm v4.6.x.
- comment out node 0.6 test due to travis-ci breakage
2017-09-07 15:57:09 -07:00
Jordan Harband
d91b6197f3
v0.33.4 2017-09-04 22:59:50 -07:00
Jordan Harband
e3d1519567 [Fix] install-latest-npm: io.js v1.0.0 has weird behavior with npm v4.6.x. 2017-09-04 22:01:46 -07:00
Jordan Harband
6f19babbff
v0.33.3 2017-09-03 12:46:59 -07:00
Jordan Harband
b3e25b15f9
nvm_install_latest_npm: npm v5.4+ breaks on node v4-4.4 and v5-5.9, due to missing Buffer.alloc. 2017-09-02 14:04:37 -07:00
Jordan Harband
cf5272e1a0 [Fix] set -u: nvm install: fix unbound vars
Fixes #1587.
2017-08-08 20:53:51 -07:00
Jordan Harband
3e1b4591bd
[New] install.sh: install bash_completion via script method.
Fixes #1588.
2017-08-08 10:11:41 -07:00
Jordan Harband
389a53cca9 [Fix] set -u: nvm use: ensure these two vars don’t error out.
Fixes #1587.
2017-08-08 00:05:38 -07:00
Peter Dave Hello
248706d5f8
[New] Clean up git reflog history before git gc 2017-07-14 00:37:58 +08:00
Peter Dave Hello
ab591b07ef [New] Print $TERM_PROGRAM in nvm debug if it exists 2017-07-14 01:48:27 +08:00
Peter Dave Hello
38a568c9c9
[New] Add --auto to git gc to speed up install & upgrade 2017-07-11 09:19:02 +08:00
GeekBlogTV
b3bdbb2712
[Docs] updated to reflect current script output 2017-07-08 01:31:13 -05:00
Mike Ferrari
6921adb2f4
[Docs] add note about Linux troubleshooting 2017-06-26 12:22:34 -07:00
Peter Dave Hello
f37ddea78f
[Docs] Fix typos in Docker instructions 2017-07-08 18:50:06 +08:00
Peter Dave Hello
1e69c4c77d
[New] Speedup process to install nvm from git by dropping commit history 2017-04-02 15:49:01 +08:00
Peter Dave Hello
3ac49e5ef1
[New] Introduce Docker environment for nvm 2017-04-02 08:03:32 +08:00
Peter Dave Hello
0356839d05 [Fix] Adjust $CURL_COMPRESSED_FLAG usage for curl, fix #1562 2017-06-27 15:04:28 +08:00
Peter Dave Hello
b5034bb2b2
[bash completion] add missing install-latest-npm; remove undocumented clear-cache 2017-06-23 14:21:10 +08:00
Jiri Spac
d073bc96c7
[Docs] bump sample version numbers 2017-06-01 16:46:53 +02:00
Peter Dave Hello
11370fe823 [Fix] curl should fail if something wrong, fix #1556 2017-06-14 10:58:38 +08:00
Jordan Harband
cbdd41eee2
[New] nvm install: add --latest-npm option to automatically try to upgrade to the latest working version of npm.
- also add `nvm install-latest-npm` top-level command
2017-06-11 14:15:04 -07:00
J Huang
28fe93cd15
[Fix] nvm install -s: properly precompute clang version 2017-06-13 13:06:53 +08:00
J Huang
7965796569
[Fix] enable curl compression only on curl >=7.21.0
curl < 7.21.0 will output redirection reponse body to the output when compressed, which will cause tarball is prepended with redirection reponse body and leads to checksum mismatch.

 - add `nvm_curl_use_compression` and `nvm_curl_version`
2017-06-10 15:25:26 +08:00
Shiva Bhusal
d2644b22f9 [Docs] Install script - Improve installation guide
If installation is prompted to be successful, yet `which nvm` command returns `not found` then you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.
2017-06-03 11:49:33 +05:45
Nicolás Bevacqua
051ef09daf Fix --version help text 2017-06-01 10:06:43 -03:00
Jordan Harband
3497474fef [Docs] move the install script to the top; put the notes in a separate section. 2017-05-26 21:09:59 -07:00
Peter Dave Hello
c3c2d350e9 [Tests] Fix cache for WITHOUT_CURL tests in Travis 2017-05-19 13:58:14 +08:00
Jordan Harband
4f626eac0d [Fix] set -u: when ALIAS is unset, don’t reference an unbound variable.
Fixes #1526.
2017-05-16 22:58:26 -07:00
Weston Ganger
7f3145bc98
[New] add support for $NVM_DIR/default-packages file 2017-03-28 09:37:14 -07:00
Jordan Harband
dc5dfe3bc1
[Fix] set IFS to default for all nvm commands.
Fixes #1227. Fixes #1244. Fixes #1514. Fixes #1518.
2017-04-28 00:41:55 -07:00
Jordan Harband
accd6ae298
[Fix] ensure if npm link fails, that $IFS is not improperly set.
https://github.com/creationix/nvm/issues/1519#issuecomment-297850323
2017-04-28 00:39:48 -07:00
Jumpei Ogawa
caa7de37af
[Fix] set -u: ensure that potentially unbound variables aren’t called unchecked.
This commit is follow up for 853afbf.
Fixes remaining bug in #1363
2017-04-27 20:17:21 +09:00
299 changed files with 12207 additions and 2188 deletions

17
.dockerignore Normal file
View File

@ -0,0 +1,17 @@
HEAD
.cache
v*
alias
# For testing
test/bak
.urchin.log
.urchin_stdout
test/**/test_output
test/**/.nvmrc
node_modules/
npm-debug.log
.DS_Store
current

35
.editorconfig Normal file
View File

@ -0,0 +1,35 @@
root = true
[*]
tab_width = 2
indent_size = 2
charset = utf-8
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.txt]
indent_size = false
[test/fast/Listing versions/Running 'nvm ls' calls into nvm_alias]
indent_size = false
[test/fast/Listing versions/Running 'nvm ls --no-alias' does not call into nvm_alias]
indent_size = false
[test/fast/Unit tests/mocks/**]
insert_final_newline = off
[test/**/.urchin*]
insert_final_newline = off
[Makefile]
indent_style = tab
[test/fixtures/nvmrc/**]
indent_style = off
insert_final_newline = off
[test/fixtures/actual/alias/empty]
insert_final_newline = off

3
.gitattributes vendored
View File

@ -1,2 +1 @@
* eol=lf
* text=auto eol=lf

12
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [ljharb]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/nvm
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@ -1,41 +0,0 @@
<!-- Thank you for being interested in nvm! Please help us by filling out the following form if youre having trouble. If you have a feature request, or some other question, please feel free to clear out the form. Thanks! -->
- Operating system and version:
- `nvm debug` output:
<details>
<!-- do not delete the following blank line -->
```sh
```
</details>
- `nvm ls` output:
<details>
<!-- do not delete the following blank line -->
```sh
```
</details>
- How did you install `nvm`? (e.g. install script in readme, homebrew):
- What steps did you perform?
- What happened?
- What did you expect to happen?
- Is there anything in any of your profile files (`.bashrc`, `.bash_profile`, `.zshrc`, etc) that modifies the `PATH`?
<!-- if this does not apply, please delete this section -->
- If you are having installation issues, or getting "N/A", what does `curl -I --compressed -v https://nodejs.org/dist/` print out?
<details>
<!-- do not delete the following blank line -->
```sh
```
</details>

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1 @@
blank_issues_enabled: false

View File

@ -0,0 +1,52 @@
---
name: File an issue…
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
<!-- Thank you for being interested in nvm! Please help us by filling out the following form if youre having trouble. If you have a feature request, or some other question, please feel free to clear out the form. Thanks! -->
#### Operating system and version:
#### `nvm debug` output:
<details>
<!-- do not delete the following blank line -->
```sh
```
</details>
#### `nvm ls` output:
<details>
<!-- do not delete the following blank line -->
```sh
```
</details>
#### How did you install `nvm`?
<!-- (e.g. install script in readme, Homebrew) -->
#### What steps did you perform?
#### What happened?
#### What did you expect to happen?
#### Is there anything in any of your profile files that modifies the `PATH`?
<!-- (e.g. `.bashrc`, `.bash_profile`, `.zshrc`, etc) -->
<!-- Please remove the following section if it does not apply to you -->
#### If you are having installation issues, or getting "N/A", what does `curl -I --compressed -v https://nodejs.org/dist/` print out?
<details>
<!-- do not delete the following blank line -->
```sh
```
</details>

27
.github/SECURITY.md vendored Normal file
View File

@ -0,0 +1,27 @@
# Security
Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report.
## OpenSSF CII Best Practices
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/684/badge)](https://bestpractices.coreinfrastructure.org/projects/684)
There are three “tiers”: passing, silver, and gold.
### Passing
We meet 100% of the “passing” criteria.
### Silver
We meet 95% of the “silver” criteria. The gaps are as follows:
- we do not have a DCO or a CLA process for contributions.
- because we only have one maintainer, the project has no way to continue if that maintainer stops being active.
- we do not currently document “what the user can and cannot expect in terms of security” for our project. This is planned to be completed in 2023.
### Gold
We meet 65% of the “gold” criteria. The gaps are as follows:
- we do not yet have the “silver” badge; see all the gaps above.
- We do not include a copyright or license statement in each source file. Efforts are underway to change this archaic practice into a suggestion instead of a hard requirement.
## Threat Model
See [THREAT_MODEL.md](./THREAT_MODEL.md).

109
.github/THREAT_MODEL.md vendored Normal file
View File

@ -0,0 +1,109 @@
# `nvm` Threat Model
## Introduction
Threat model analysis assists organizations to proactively identify potential security threats and vulnerabilities, enabling them to develop effective strategies to mitigate these risks before they are exploited by attackers.
Furthermore, this often helps to improve the overall security and resilience of a system or application.
The aim of this section is to facilitate the identification of potential security threats and vulnerabilities that may be exploited by adversaries, along with possible outcomes and appropriate mitigations.
## Relevant assets and threat actors
The following assets are considered important for the `nvm` project:
- `nvm` source code and project documentation
- Underlying `nvm` dependencies
- `nvm` development infrastructure
- `nvm` installed devices including servers
The following threat actors are considered relevant to the `nvm` application:
- External malicious attackers
- Internal malicious attackers
- Services
- Malicious insider actors
- Third-party libraries
## Attack surface for external/internal attackers and services
In threat modeling, an attack surface refers to any possible point of entry that an attacker might use to exploit a system or application.
This includes all the paths and interfaces that an attacker may use to access, manipulate or extract sensitive data from a system.
By understanding the attack surface, organizations are typically able to identify potential attack vectors and implement appropriate countermeasures to mitigate risks.
In the following diagrams, _External Malicious Attacker_ applies to threat actors who do not yet have direct access to the `nvm` application and the underlying operating system, while the _Internal Malicious Attacker_ applies to an attacker with access to the device (computer, server), potentially after successfully exploiting a threat from the _External Malicious Attacker_ scenario.
**Please note that some of the external threats may be also exploitable from internal threats and vice versa.**
<img src="./external-threat-actor.png" alt="Fig.: Possible attacks from internal and external threat actors and services" />
Fig.: Possible attacks from internal and external threat actors and services
## Identified threats
The identified threats against the `nvm` application are as follows:
### Threat ID 1: `nvm` commands
Overview: The `nvm` commands and subcommands take user input for handling and executing appropriate functions from the project directory (or any parent directory).
When user-controlled inputs are not adequately validated and later passed to the `nvm` functions as a part of a command, an attacker might be able to execute operating system commands triggered by any parsing functionality.
Possible Outcome: Attacks against `nvm` commands could lead to unauthorized access to user data or unauthorized access to the device (i.e. laptop or server, depending on where `nvm` is installed), resulting in loss of user private data stored on the device, among other possibilities.
Recommendation: Input validation should be implemented to prevent attackers from requesting operating system commands.
Similarly, secure coding practices ought to be in place to minimize the risk of buffer overflow vulnerabilities.
### Threat ID 2: URI scheme
Overview: `nvm` commands heavily use the [Secure HyperText Transfer](https://datatracker.ietf.org/doc/html/rfc2660) protocol for `nvm` related actions.
Missing [scheme](https://datatracker.ietf.org/doc/html/rfc3986#section-3.1) validation for any `nvm` command might result in file retrieval, enumeration, file overwrite, or [path traversal](https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/05-Authorization_Testing/01-Testing_Directory_Traversal_File_Include) attacks.
An example of this could be path validation for [`nvm_download`](https://github.com/nvm-sh/nvm/blob/ef7fc2f2c06ad75fe7fbabf28d427561ae7b007d/nvm.sh#L118), among many other possibilities.
Possible Outcome: Security misconfiguration flaws for URI scheme may lead to unauthorized access to user data, as well as data integrity compromises.
Recommendation: Adequate input validation should be implemented to prevent attackers from enumerating, retrieving and writing to application files and paths.
### Threat ID 3: Communication channel
Overview: The `nvm` commands and its subcommands use network protocol to communicate with external services.
Insecure communication may allow malicious attackers to perform [_Man-in-the-Middle_](https://owasp.org/www-community/attacks/Manipulator-in-the-middle_attack) attacks in order to manipulate the data sent during the users active connection.
Possible Outcome: Usage of plaintext communication protocols, like HTTP could lead to data sniffing and modification through insecure communications channels.
Recommendation: Mitigation countermeasures such as data encryption should be in place to prevent data manipulation via insecure communication channels.
### Threat ID 4: Environment variables
Overview: Each `nvm` installation defines its environment variables, which should be secured from internal malicious attackers, preventing access control attack vectors.
Missing stringent restrictions on setting variables, might allow attackers to prepare various targeted attacks against other local users, who use `nvm` in their user space.
For example, [_Privilege Escalation_](https://owasp.org/Top10/A01_2021-Broken_Access_Control/), [_Command Injection_](https://cwe.mitre.org/data/definitions/77.html), as well as many other parser-related attacks.
Possible Outcome: Attacks against environment variables could lead to unauthorized access to the user space, resulting in the loss of user private data and disruptions in service availability.
Recommendation: Adequate hardening of configuration file permissions should be in place for all relevant configuration files, as this provides protection against attackers able to manipulate variables and inject malicious code.
## Attack surface for malicious insider actors and third-party libraries
The following diagram summarizes the main possible threats against the `nvm` project from malicious insider actors and third-party libraries:
<img src="./insider-threat-actor-and-libs.png" alt="Fig.: Possible attacks from insider threat actors and third-party libraries" />
Fig.: Possible attacks from insider threat actors and third-party libraries
The identified threats against the `nvm` project are as follows:
### Threat ID 1: Insider threat actor
**Overview**: An insider threat actor, such as an `nvm` project contributor or employee with access to the code base, might abuse their role in the organization to modify the `nvm` application source code.
For example, intentionally adding malicious code snippets, clearing logs after being written and/or modifying specific sections of the documentation.
**Possible Outcome**: Reputation damage, financial losses.
**Recommendation**: Secure coding practices, code reviews, automated code scanning and separation of duties (i.e. requiring at least two developers to approve any code change) are potentially useful security controls to identify and mitigate vulnerabilities that may be introduced by an insider threat actor.
### Threat ID 2: Third-party libraries
**Overview**: Please note that while `nvm` does not currently make use of any third-party libraries, this might become an attack vector if that changes in the future.
Third-party libraries may introduce potential risks related to maintaining security requirements by third-party vendors.
As a result, third-party libraries used by the `nvm` project, might contain vulnerabilities, such as [_Buffer Overflows_](https://owasp.org/www-community/vulnerabilities/Buffer_Overflow), [_Format String Vulnerabilities_](https://owasp.org/www-community/attacks/Format_string_attack), as well as many other types of weaknesses that, in a worst-case scenario may lead to _Remote Code Execution_ (_RCE_).
Additionally, the maintainer of a third-party dependency might introduce a vulnerability on purpose, or be compromised by an attacker that subsequently introduces vulnerable code.
**Possible Outcome**: Code vulnerabilities may lead to unauthorized access to user data, loss of user private data, service disruptions and reputation damage.
**Recommendation**: Third-party libraries should be kept up-to-date, applying patches to address publicly known vulnerabilities in a timely fashion.
Monitoring and logging capabilities should also be in place to detect and respond to potential attacks.
SLSA compliance may also be considered for further supply chain security hardening.

BIN
.github/external-threat-actor.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

86
.github/workflows/latest-npm.yml vendored Normal file
View File

@ -0,0 +1,86 @@
name: 'Tests: `nvm install-latest-npm`'
on: [pull_request, push]
permissions:
contents: read
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
allowed-endpoints:
iojs.org:443
nodejs.org:443
raw.githubusercontent.com:443
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
versionsAsRoot: true
type: majors
preset: '>=1'
nodes:
needs: [matrix]
permissions:
contents: read
name: 'nvm install-latest-npm'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
include:
- node-version: "21"
- node-version: "20.5"
- node-version: "20.4"
- node-version: "14.17"
- node-version: "14.16"
- node-version: "9.2"
- node-version: "9.1"
- node-version: "9.0"
- node-version: "6.1"
- node-version: "5.9"
- node-version: "4.6"
- node-version: "4.5"
- node-version: "4.4"
- node-version: "0.12"
- node-version: "0.10"
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
allowed-endpoints:
github.com:443
raw.githubusercontent.com:443
iojs.org:443
nodejs.org:443
registry.npmjs.org:443
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main
name: 'install node'
with:
node-version: ${{ matrix.node-version }}
skip-ls-check: true
skip-install: true
skip-latest-npm: true
- run: npm --version
- run: '. ./nvm.sh ; nvm install-latest-npm'
name: 'nvm install-latest-npm'
- run: npm --version
node:
permissions:
contents: none
name: 'nvm install-latest-npm'
needs: [nodes]
runs-on: ubuntu-latest
steps:
- run: true

72
.github/workflows/lint.yml vendored Normal file
View File

@ -0,0 +1,72 @@
name: 'Tests: linting'
on: [pull_request, push]
permissions:
contents: read
jobs:
eclint:
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@v2
with:
allowed-endpoints:
github.com:443
raw.githubusercontent.com:443
nodejs.org:443
registry.npmjs.org:443
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
node-version: 'lts/*'
- run: npm run eclint
dockerfile_lint:
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@v2
with:
allowed-endpoints:
ghcr.io:443
github.com:443
raw.githubusercontent.com:443
pkg-containers.githubusercontent.com:443
nodejs.org:443
registry.npmjs.org:443
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
node-version: 'lts/*'
- run: npm run dockerfile_lint
doctoc:
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@v2
with:
allowed-endpoints:
github.com:443
raw.githubusercontent.com:443
nodejs.org:443
registry.npmjs.org:443
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
with:
node-version: 'lts/*'
- run: npm run doctoc:check
test_naming:
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@v2
with:
allowed-endpoints:
github.com:443
raw.githubusercontent.com:443
- uses: actions/checkout@v4
- name: check tests filenames
run: ./rename_test.sh --check

104
.github/workflows/nvm-install-test.yml vendored Normal file
View File

@ -0,0 +1,104 @@
name: 'Tests: nvm install with set -e'
on:
pull_request:
push:
workflow_dispatch:
inputs:
ref:
description: 'git ref to use'
required: false
default: 'HEAD'
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: matrix
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.ref }}" ]; then
echo "matrix=\"[\"${{ github.event.inputs.ref }}\"]\"" >> $GITHUB_OUTPUT
else
TAGS="$((echo "HEAD" && git tag --sort=-v:refname --merged HEAD --format='%(refname:strip=2) %(creatordate:short)' | grep '^v' | while read tag date; do
if [ "$(uname)" == "Darwin" ]; then
timestamp=$(date -j -f "%Y-%m-%d" "$date" +%s)
threshold=$(date -j -v-4y +%s)
else
timestamp=$(date -d "$date" +%s)
threshold=$(date -d "4 years ago" +%s)
fi
if [ $timestamp -ge $threshold ]; then echo "$tag"; fi
done) | xargs)"
echo $TAGS
TAGS_JSON=$(printf "%s\n" $TAGS | jq -R . | jq -sc .)
echo "matrix=${TAGS_JSON}" >> $GITHUB_OUTPUT
fi
test:
needs: [matrix]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.ref == 'v0.40.0' }} # https://github.com/nvm-sh/nvm/issues/3405
strategy:
fail-fast: false
matrix:
ref: ${{ fromJson(needs.matrix.outputs.matrix) }}
has-nvmrc:
- 'no nvmrc'
- 'nvmrc'
shell-level:
- 1 shlvl
- 2 shlvls
steps:
- uses: actions/checkout@v4
- name: resolve HEAD to sha
run: |
if [ '${{ matrix.ref }}' = 'HEAD' ]; then
REF="$(git rev-parse HEAD)"
else
REF="${{ matrix.ref }}"
fi
echo "resolved ref: ${REF}"
echo "ref="$REF"" >> $GITHUB_ENV
- run: echo $- # which options are set
- run: echo node > .nvmrc
if: ${{ matrix.has-nvmrc == 'nvmrc' }}
- run: curl -I --compressed -v https://nodejs.org/dist/
- name: 'install nvm'
run: |
set -e
export NVM_INSTALL_VERSION="${ref}"
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/${ref}/install.sh" | bash
- name: nvm --version
run: |
set +e
. $NVM_DIR/nvm.sh && nvm --version
- name: nvm install in 1 shell level, ${{ matrix.has-nvmrc }}
if: ${{ matrix.shell-level == '1 shlvl' }}
run: |
set -ex
. $NVM_DIR/nvm.sh
echo nvm.sh sourced
nvm --version
if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then
nvm install
fi
- name: nvm install in 2 shell levels, ${{ matrix.has-nvmrc }}
if: ${{ matrix.shell-level == '2 shlvls' }}
run: |
if [ '${{ matrix.has-nvmrc }}' == 'nvmrc' ]; then
bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version && nvm install"
else
bash -c "set -ex && . $NVM_DIR/nvm.sh && echo nvm.sh sourced && nvm --version"
fi
finisher:
runs-on: ubuntu-latest
needs: [test]
steps:
- run: true

26
.github/workflows/rebase.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Automatic Rebase
on: [pull_request_target]
permissions:
contents: read
jobs:
_:
permissions:
contents: write
name: "Automatic Rebase"
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
allowed-endpoints:
api.github.com:443
github.com:443
- uses: actions/checkout@v4
- uses: ljharb/rebase@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

38
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: 'Tests: release process'
on: [pull_request, push]
permissions:
contents: read
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
allowed-endpoints:
github.com:443
api.github.com:443
objects.githubusercontent.com:443
raw.githubusercontent.com:443
registry.npmjs.org:443
- uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/setup-node@v4
with:
node-version: "14"
- run: npm install
- name: Configure git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git fetch --unshallow --tags -f || git fetch --tags -f
- name: Attempt `make release` process
run: echo proceed | make TAG=99.99.99 release
env:
GIT_EDITOR: "sed -i '1 s/^/99.99.99 make release test/'"
- name: Ensure tag is created
run: git tag | grep v99.99.99

View File

@ -0,0 +1,24 @@
name: Require “Allow Edits”
on: [pull_request_target]
permissions:
contents: read
jobs:
_:
permissions:
pull-requests: read
name: "Require “Allow Edits”"
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
allowed-endpoints:
api.github.com:443
- uses: ljharb/require-allow-edits@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

56
.github/workflows/shellcheck.yml vendored Normal file
View File

@ -0,0 +1,56 @@
name: 'Tests: shellcheck'
on: [pull_request, push]
permissions:
contents: read
jobs:
shellcheck_matrix:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shell:
- bash
- sh
- dash
- ksh
file:
- nvm.sh
include:
- shell: bash
file: install.sh # only supported on bash
- shell: bash
file: bash_completion # only needed in bash/zsh
- shell: bash
file: nvm-exec # only runs in bash
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
allowed-endpoints:
ghcr.io:443
github.com:443
pkg-containers.githubusercontent.com:443
formulae.brew.sh:443
- uses: actions/checkout@v4
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install latest shellcheck
run: brew install shellcheck
env:
HOMEBREW_NO_ANALYTICS: 1
- run: which shellcheck
- run: shellcheck --version
- name: Run shellcheck on ${{ matrix.file }}
run: shellcheck -s ${{ matrix.shell }} ${{ matrix.file }}
shellcheck:
permissions:
contents: none
needs: [shellcheck_matrix]
runs-on: ubuntu-latest
steps:
- run: true

80
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,80 @@
name: urchin tests
on: [push, pull_request]
permissions:
contents: read
jobs:
tests:
permissions:
contents: write
name: "tests"
runs-on: ubuntu-latest
defaults:
run:
shell: 'script -q -e -c "${{ matrix.shell }} {0}"'
strategy:
fail-fast: false
matrix:
exclude:
- shell: sh
suite: install_script
- shell: dash
suite: install_script
- shell: zsh
suite: install_script
- shell: ksh
suite: install_script
suite:
- install_script
- sourcing
- slow
- installation_iojs
shell:
- sh
- bash
- dash
- zsh
# - ksh
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
allowed-endpoints:
github.com:443
registry.npmjs.org:443
raw.githubusercontent.com:443
nodejs.org:443
iojs.org:443
azure.archive.ubuntu.com:80
packages.microsoft.com:443
- uses: actions/checkout@v4
- run: sudo apt-get update; sudo apt-get install ${{ matrix.shell }}
if: matrix.shell == 'zsh' || matrix.shell == 'ksh'
# zsh (https://github.com/actions/runner-images/issues/264) and ksh are not in the ubuntu image
shell: bash
- run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
- run: curl --version
- run: wget --version
- uses: ljharb/actions/node/install@main
name: 'npm install && version checks'
with:
node-version: 'lts/*'
skip-ls-check: true
- run: npm ls urchin
- run: npx which urchin
- run: env
- run: make TERM=xterm-256color TEST_SUITE="${{ matrix.suite }}" SHELL="${{ matrix.shell }}" URCHIN="$(npx which urchin)" test-${{ matrix.shell }}
nvm:
permissions:
contents: none
name: 'all test suites, all shells'
needs: [tests]
runs-on: ubuntu-latest
steps:
- run: true

41
.github/workflows/toc.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: update readme TOC
on: [push]
permissions:
contents: read
jobs:
_:
permissions:
contents: write
name: "update readme TOC"
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:
allowed-endpoints:
github.com:443
registry.npmjs.org:443
api.github.com:443
- uses: actions/checkout@v4
with:
# https://github.com/actions/checkout/issues/217#issue-599945005
# pulls all commits (needed for lerna / semantic release to correctly version)
fetch-depth: "0"
# pulls all tags (needed for lerna / semantic release to correctly version)
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- run: npm install
- run: npm run doctoc
- name: commit changes
uses: ljharb/actions-js-build/commit@v3+amendpush
with:
amend: true
force: true

193
.github/workflows/windows-npm.yml vendored Normal file
View File

@ -0,0 +1,193 @@
name: 'Tests on Windows: `nvm install`'
on: [pull_request, push]
permissions:
contents: read
env:
NVM_INSTALL_GITHUB_REPO: ${{ github.repository }}
NVM_INSTALL_VERSION: ${{ github.sha }}
jobs:
msys_fail_install:
# Default installation does not work due to npm_config_prefix set to C:\npm\prefix
permissions:
contents: none
name: 'MSYS fail prefix nvm install'
runs-on: windows-latest
steps:
- name: Retrieve nvm
shell: bash
run: |
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash
. "$HOME/.nvm/nvm.sh"
! nvm install --lts
msys_matrix:
permissions:
contents: none
name: 'MSYS nvm install'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
npm-node-version:
- '--lts'
- '--default 12'
- '--no-progress 10'
steps:
- name: Retrieve nvm
shell: bash
run: |
unset npm_config_prefix
if [ "${{ matrix.npm-node-version }}" = "--lts" ]; then
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
else
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash
fi
. "$HOME/.nvm/nvm.sh"
nvm install ${{ matrix.npm-node-version }}
cygwin_matrix:
continue-on-error: true
permissions:
contents: none
name: 'Cygwin nvm install'
runs-on: windows-latest
steps:
- name: Install Cygwin
shell: bash
run: |
export SITE='https://mirror.clarkson.edu/cygwin/' # see https://archlinux.org/mirrors/clarkson.edu/1603/ for uptime status
export SITE='https://mirrors.kernel.org/sourceware/cygwin/'
export LOCALDIR="$(pwd)"
export ROOTDIR="$USERPROFILE\\cygwin"
export PACKAGES='bash,git,curl'
curl -fsSLo setup-x86_64.exe 'https://cygwin.com/setup-x86_64.exe'
./setup-x86_64.exe --disable-buggy-antivirus -q -s "$SITE" -l "$LOCALDIR" -R "$ROOTDIR" -P "$PACKAGES"
cat >~/setup.sh <<EOM
unset npm_config_prefix
export NVM_INSTALL_GITHUB_REPO="$NVM_INSTALL_GITHUB_REPO"
export NVM_INSTALL_VERSION="$NVM_INSTALL_VERSION"
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
. "$HOME/.nvm/nvm.sh"
nvm install --lts
nvm deactivate
rm -rf "$HOME/.nvm/nvm.sh"
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD=script bash
. "$HOME/.nvm/nvm.sh"
nvm install 9
EOM
- name: Retrieve nvm
shell: cmd
run: |
cd %USERPROFILE%\cygwin\bin
bash.exe "%USERPROFILE%\setup.sh"
wsl_matrix:
continue-on-error: true
name: 'WSL nvm install'
defaults:
run:
shell: wsl-bash {0}
runs-on: windows-latest
env:
WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p
strategy:
fail-fast: false
matrix:
wsl-distrib:
- Debian
# - Alpine # fails
- Ubuntu-20.04
- Ubuntu-18.04
npm-node-version:
- '--lts'
- '21'
- '18'
- '16'
- '14'
- '12'
- '10'
exclude:
- wsl-distrib: Ubuntu-18.04
npm-node-version: '--lts'
- wsl-distrib: Ubuntu-18.04
npm-node-version: '21'
- wsl-distrib: Ubuntu-18.04
npm-node-version: '18'
method:
- ''
- 'script'
steps:
- uses: Vampire/setup-wsl@v3
with:
distribution: ${{ matrix.wsl-distrib }}
additional-packages: bash git curl ca-certificates wget
- name: Retrieve nvm on WSL
run: |
if [ -z "${{ matrix.method }}" ]; then
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
else
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash
fi
. "$HOME/.nvm/nvm.sh"
nvm install ${{ matrix.npm-node-version }}
node -v
wsl_matrix_unofficial:
continue-on-error: true
name: 'WSL nvm install'
defaults:
run:
shell: wsl-bash {0}
runs-on: windows-latest
env:
WSLENV: NVM_INSTALL_GITHUB_REPO:NVM_INSTALL_VERSION:/p
NVM_NODEJS_ORG_MIRROR: https://unofficial-builds.nodejs.org/download/release
strategy:
fail-fast: false
matrix:
wsl-distrib:
- Alpine
npm-node-version:
- '--lts'
- '21'
- '18'
- '16'
- '14'
- '12'
- '11'
- '10'
method:
- ''
- 'script'
steps:
- uses: Vampire/setup-wsl@v3
with:
distribution: ${{ matrix.wsl-distrib }}
additional-packages: bash git curl ca-certificates wget
- name: Retrieve nvm on WSL
run: |
if [ -z "${{ matrix.method }}" ]; then
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | bash
else
curl -fsSLo- "https://raw.githubusercontent.com/${NVM_INSTALL_GITHUB_REPO}/${NVM_INSTALL_VERSION}/install.sh" | METHOD="${{matrix.method}}" bash
fi
. "$HOME/.nvm/nvm.sh"
NVM_NODEJS_ORG_MIRROR=${{ env.NVM_NODEJS_ORG_MIRROR }} nvm install ${{ matrix.npm-node-version }}
nvm_windows:
name: 'tests, on windows'
permissions:
contents: none
needs: [wsl_matrix, wsl_matrix_unofficial, cygwin_matrix, msys_matrix, msys_fail_install]
runs-on: ubuntu-latest
steps:
- run: true

10
.gitignore vendored
View File

@ -1,3 +1,4 @@
# gitignore
HEAD
.cache
v*
@ -8,9 +9,18 @@ test/bak
.urchin.log
.urchin_stdout
test/**/test_output
test/**/.nvmrc
node_modules/
npm-debug.log
.DS_Store
current
/default-packages
# Only apps should have lockfiles
npm-shrinkwrap.json
package-lock.json
yarn.lock
target/

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "test/fixtures/nvmrc"]
path = test/fixtures/nvmrc
url = git@github.com:nvm-sh/nvmrc.git

1
.mailmap Normal file
View File

@ -0,0 +1 @@
Michał Gołębiowski-Owczarek <m.goleb@gmail.com>

1
.npmrc Normal file
View File

@ -0,0 +1 @@
package-lock=false

View File

@ -1,82 +1,94 @@
language: generic
dist: trusty
sudo: required
dist: focal
addons:
apt:
packages:
- cabal-install
- ghc
- zsh
# - ksh
# - gcc-4.8
# - g++-4.8
# https://gist.github.com/iedemam/9830045
git:
submodules: false
cache:
ccache: true
directories:
- $HOME/.npm
- $HOME/.ghc
- $HOME/.cabal
- $TRAVIS_BUILD_DIR/.cache
- $TRAVIS_BUILD_DIR/node_modules
before_install:
- sudo sed -i 's/mozilla\/DST_Root_CA_X3.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf
- sudo update-ca-certificates -f
# https://gist.github.com/iedemam/9830045
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
- $SHELL --version 2> /dev/null || dpkg -s $SHELL 2> /dev/null || which $SHELL
- curl --version
- wget --version
- bash --version | head
- zsh --version
- dpkg -s dash | grep ^Version | awk '{print $2}'
# install python
- pyenv local 2.7.18 || pyenv install 2.7.18
- pyenv local 2.7.18 || echo 'pyenv failed'
- python -V
install:
- if [ -n "${SHELLCHECK-}" ]; then cabal update && cabal install ShellCheck && shellcheck --version ; fi
- if [ -z "${SHELLCHECK-}" ]; then nvm install node && npm install && npm prune && npm ls urchin doctoc; fi
- if [ -z "${SHELLCHECK-}" ]; then nvm install 16 && nvm unalias default && npm install && npm prune && npm ls urchin doctoc eclint dockerfile_lint; fi
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
script:
- if [ -n "${MAKE_RELEASE-}" ]; then export GIT_EDITOR="sed -i '1 s/^/99.99.99 make release test/'" && git fetch --unshallow --tags && echo proceed | make TAG=99.99.99 release ; fi
- if [ -n "${DOCTOCCHECK-}" ]; then cp README.md README.md.orig && npm run doctoc && diff -q README.md README.md.orig ; fi
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash nvm.sh && shellcheck -s sh nvm.sh && shellcheck -s dash nvm.sh && shellcheck -s ksh nvm.sh ; fi
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash install.sh bash_completion nvm-exec ; fi
- if [ -n "${SHELL-}" ] && [ -n "${TEST_SUITE}" ]; then make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL ; fi
after_success:
- if [ -n "${SHELL-}" ] && [ -n "${TEST_SUITE}" ]; then if [ "${TEST_SUITE}" = 'installation_iojs' ] || [ "${TEST_SUITE}" = 'xenial' ]; then travis_retry make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL ; else make TEST_SUITE=$TEST_SUITE URCHIN="$(npm bin)/urchin" test-$SHELL; fi; fi
before_cache:
- if [ -n "$WITHOUT_CURL" ]; then sudo apt-get install curl -y ; fi
jobs:
include:
- env: SHELL=bash TEST_SUITE=installation_node
dist: xenial
- env: SHELL=bash TEST_SUITE=installation_node WITHOUT_CURL=1
dist: xenial
- env: SHELL=sh TEST_SUITE=installation_node
dist: xenial
- env: SHELL=sh TEST_SUITE=installation_node WITHOUT_CURL=1
dist: xenial
- env: SHELL=dash TEST_SUITE=installation_node
dist: xenial
- env: SHELL=dash TEST_SUITE=installation_node WITHOUT_CURL=1
dist: xenial
- env: SHELL=zsh TEST_SUITE=installation_node
dist: xenial
- env: SHELL=zsh TEST_SUITE=installation_node WITHOUT_CURL=1
dist: xenial
#- env: SHELL=ksh TEST_SUITE=installation_node
# dist: xenial
#- env: SHELL=ksh TEST_SUITE=installation_node WITHOUT_CURL=1
# dist: xenial
- env: SHELL=bash TEST_SUITE=xenial
dist: xenial
- env: SHELL=sh TEST_SUITE=xenial
dist: xenial
- env: SHELL=dash TEST_SUITE=xenial
dist: xenial
- env: SHELL=zsh TEST_SUITE=xenial
dist: xenial
#- env: SHELL=ksh TEST_SUITE=xenial
# dist: xenial
env:
global:
- CXX=g++-4.8
- CC=gcc-4.8
- PATH="~/.cabal/bin/:$(echo $PATH | sed 's/::/:/')"
- CXX=g++
- CC=gcc
- PATH="$(echo $PATH | sed 's/::/:/')"
- PATH="/usr/lib/ccache/:$PATH"
- NVM_DIR="${TRAVIS_BUILD_DIR}"
matrix:
- MAKE_RELEASE=true
- DOCTOCCHECK=true
- SHELLCHECK=true
- SHELL=bash TEST_SUITE=install_script
- SHELL=sh TEST_SUITE=fast
- SHELL=dash TEST_SUITE=fast
- SHELL=bash TEST_SUITE=fast
- SHELL=zsh TEST_SUITE=fast
# - SHELL=ksh TEST_SUITE=fast
- SHELL=sh TEST_SUITE=sourcing
- SHELL=dash TEST_SUITE=sourcing
- SHELL=bash TEST_SUITE=sourcing
- SHELL=zsh TEST_SUITE=sourcing
# - SHELL=ksh TEST_SUITE=sourcing
- SHELL=sh TEST_SUITE=slow
- SHELL=dash TEST_SUITE=slow
- SHELL=bash TEST_SUITE=slow
- SHELL=zsh TEST_SUITE=slow
# - SHELL=ksh TEST_SUITE=slow
- SHELL=sh TEST_SUITE=installation_node
- SHELL=sh TEST_SUITE=installation_node WITHOUT_CURL=1
- SHELL=dash TEST_SUITE=installation_node
- SHELL=dash TEST_SUITE=installation_node WITHOUT_CURL=1
- SHELL=bash TEST_SUITE=installation_node
- SHELL=bash TEST_SUITE=installation_node WITHOUT_CURL=1
- SHELL=zsh TEST_SUITE=installation_node
- SHELL=zsh TEST_SUITE=installation_node WITHOUT_CURL=1
# - SHELL=ksh TEST_SUITE=installation_node
# - SHELL=ksh TEST_SUITE=installation_node WITHOUT_CURL=1
- SHELL=sh TEST_SUITE=installation_iojs
# - SHELL=ksh TEST_SUITE=fast
- SHELL=sh TEST_SUITE=installation_iojs WITHOUT_CURL=1
- SHELL=dash TEST_SUITE=installation_iojs
- SHELL=dash TEST_SUITE=installation_iojs WITHOUT_CURL=1
- SHELL=bash TEST_SUITE=installation_iojs
- SHELL=bash TEST_SUITE=installation_iojs WITHOUT_CURL=1
- SHELL=zsh TEST_SUITE=installation_iojs
- SHELL=zsh TEST_SUITE=installation_iojs WITHOUT_CURL=1
# - SHELL=ksh TEST_SUITE=installation_iojs
# - SHELL=ksh TEST_SUITE=installation_iojs WITHOUT_CURL=1
# - SHELL=ksh TEST_SUITE=installation_iojs WITHOUT_CURL=1

125
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,125 @@
# Code of Conduct
`nvm`, as a member project of the OpenJS Foundation, uses [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) as their code of conduct. The full text is included [below](#contributor-covenant-code-of-conduct) in English, and translations are available from the Contributor Covenant organisation:
- [contributor-covenant.org/translations](https://www.contributor-covenant.org/translations)
- [github.com/ContributorCovenant](https://github.com/ContributorCovenant/contributor_covenant/tree/release/content/version/2/1)
Refer to the sections on reporting and escalation in this document for the specific emails that can be used to report and escalate issues.
## Reporting
### Project Spaces
For reporting issues in spaces related to `nvm` please use the email `ljharb@gmail.com`. `nvm` handles CoC issues related to the spaces that it maintains. Projects maintainers commit to:
- maintain the confidentiality with regard to the reporter of an incident
- to participate in the path for escalation as outlined in the section on Escalation when required.
### Foundation Spaces
For reporting issues in spaces managed by the OpenJS Foundation, for example, repositories within the OpenJS organization, use the email `report@lists.openjsf.org`.
The Cross Project Council (CPC) is responsible for managing these reports and commits to:
- maintain the confidentiality with regard to the reporter of an incident
- to participate in the path for escalation as outlined in the section on Escalation when required.
## Escalation
The OpenJS Foundation maintains a Code of Conduct Panel (CoCP).
This is a foundation-wide team established to manage escalation when a reporter believes that a report to a member project or the CPC has not been properly handled.
In order to escalate to the CoCP send an email to `coc-escalation@lists.openjsf.org`.
For more information, refer to the full [Code of Conduct governance document](https://github.com/openjs-foundation/cross-project-council/blob/HEAD/CODE_OF_CONDUCT.md).
---
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [@ljharb](ljharb@gmail.com).
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of actions.
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

View File

@ -1,20 +1,123 @@
Thanks for contributing to `nvm`!
# Contributing
:+1::tada: First off, thanks for taking the time to contribute to `nvm`! :tada::+1:
We love pull requests and issues, they're our favorite.
The following is a set of guidelines for contributing to `nvm` managed by [@LJHarb](https://github.com/ljharb), which is hosted on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
However, before submitting, please review the following:
For bug reports:
- Please make sure the bug is reproducible, and give us the steps to reproduce it, so that we can dig into the problem.
- Please give us as much detail as possible about your environment, so we can more easily confirm the problem.
# How Can I Contribute?
For pull requests:
- Please include tests. Changes with tests will be merged very quickly.
- Please manually confirm that your changes work in `bash`, `sh`/`dash`, `ksh`, and `zsh`. Fast tests do run in these shells, but it's nice to manually verify also.
- Please maintain consistent whitespace - 2-space indentation, trailing newlines in all files, etc.
- Any time you make a change to your PR, please rebase freshly on top of master. Nobody likes merge commits.
There are lots of ways to get involved. Here are some suggestions of things we'd love some help with.
## Resolving existing issues
You can consider helping out with issues already requiring attention - look for a "help wanted" label.
### How Do I Submit a (Good) Bug Report? :bug:
Explain the problem and include additional details to help maintainers reproduce the problem:
* **Use a clear and descriptive title** for the issue to identify the problem.
* **Describe the exact steps which reproduce the problem** in as many details as possible. For example, start by explaining which command exactly you used in the terminal. When listing steps, **don't just say what you did, but explain how you did it**. For example, if you moved the cursor to the end of a line, explain if you used the mouse, or a keyboard shortcut or a command, and if so which one?
* **Provide specific examples to demonstrate the steps**. Include links to files or Github projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines).
* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
* **Explain which behavior you expected to see instead and why.**
* **Provide as much context as possible** in order to help others verify and ultimately fix the issue. This includes giving us as much details as possible about your environment, so we can more easily confirm the problem.
## Documentation
We are happy to welcome contributions from anyone willing to improve documentation by adding missing information or making it more consistent and coherent.
# Dev Environment
Please refer to the [README](README.md) for complete instructions how to install, update, as well as troubleshoot `nvm` in your environment depending on your Operating System.
# Style Guide / Coding conventions
### Pull requests
#### Before creating a pull request
- Please include tests. Changes with tests will be merged very quickly.
- Please manually confirm that your changes work in `bash`, `sh`/`dash`, `ksh`, and `zsh`. Fast tests do run in these shells, but it's nice to manually verify also.
- Please maintain consistent whitespace - 2-space indentation, trailing newlines in all files, etc.
- Any time you make a change to your PR, please rebase freshly on top of the default branch. Nobody likes merge commits.
Even if you don't have all of these items covered, please still feel free to submit a PR/issue! Someone else may be inspired and volunteer to complete it for you.
Thanks again!
#### How to create a pull request
Create a new branch
```
git checkout -b issue1234
```
Commit the changes to your branch, including a coherent commit message that follows our [standards](#commit-messages)
```
git commit -a
```
Before sending the pull request, make sure your code is running on the latest available code by rebasing onto the upstream source
```
git fetch upstream
git rebase upstream/main
```
Verify your changes
```
npm test
```
Push your changes
```
git push origin issue1234
```
Send the [pull request](https://docs.github.com/en/pull-requests), make requested changes, and get merged.
### Commit Messages
* Limit the first line of the commit message (message summary) to 72 characters or less.
* Use the present tense ("Add feature" not "Added feature") and imperative mood ("Move cursor to..." not "Moves cursor to...") when providing a description of what you did.
* If your PR addresses an issue, reference it in the body of the commit message.
* See the rest of the conventions [here](https://gist.github.com/ljharb/772b0334387a4bee89af24183114b3c7)
#### Commit message example
```
[Tag]: Short description of what you did
Longer description here if necessary
Fixes #1234
```
> **Note:** Add co-authors to your commit message for commits with multiple authors
```
Co-authored-by: Name Here <email@here>
```
# Code of Conduct
[Code of Conduct](https://github.com/nvm-sh/nvm/blob/HEAD/CODE_OF_CONDUCT.md)
# Where can I ask for help?
If you have any questions, please contact [@LJHarb](mailto:ljharb@gmail.com).
# Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
- The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
- The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
- The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
- I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.

112
Dockerfile Normal file
View File

@ -0,0 +1,112 @@
# Dockerized nvm development environment
#
# This Dockerfile is for building nvm development environment only,
# not for any distribution/production usage.
#
# Please note that it'll use about 1.2 GB disk space and about 15 minutes to
# build this image, it depends on your hardware.
FROM ubuntu:22.04
LABEL maintainer="Peter Dave Hello <hsu@peterdavehello.org>"
LABEL name="nvm-dev-env"
LABEL version="latest"
# Set the SHELL to bash with pipefail option
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Prevent dialog during apt install
ENV DEBIAN_FRONTEND noninteractive
# ShellCheck version
ENV SHELLCHECK_VERSION=0.7.0
# Pick a Ubuntu apt mirror site for better speed
# ref: https://launchpad.net/ubuntu/+archivemirrors
ENV UBUNTU_APT_SITE ubuntu.cs.utah.edu
# Replace origin apt package site with the mirror site
RUN sed -E -i "s/([a-z]+.)?archive.ubuntu.com/$UBUNTU_APT_SITE/g" /etc/apt/sources.list
RUN sed -i "s/security.ubuntu.com/$UBUNTU_APT_SITE/g" /etc/apt/sources.list
# Install apt packages
RUN apt update && \
apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" && \
apt install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
coreutils \
util-linux \
bsdutils \
file \
openssl \
libssl-dev \
locales \
ca-certificates \
ssh \
wget \
patch \
sudo \
htop \
dstat \
vim \
tmux \
curl \
git \
jq \
zsh \
ksh \
gcc \
g++ \
xz-utils \
build-essential \
bash-completion && \
apt-get clean
RUN wget https://github.com/koalaman/shellcheck/releases/download/v$SHELLCHECK_VERSION/shellcheck-v$SHELLCHECK_VERSION.linux.x86_64.tar.xz -O- | \
tar xJvf - shellcheck-v$SHELLCHECK_VERSION/shellcheck && \
mv shellcheck-v$SHELLCHECK_VERSION/shellcheck /bin && \
rmdir shellcheck-v$SHELLCHECK_VERSION
RUN shellcheck -V
# Set locale
RUN locale-gen en_US.UTF-8
# Print tool versions
RUN bash --version | head -n 1
RUN zsh --version
RUN ksh --version || true
RUN dpkg -s dash | grep ^Version | awk '{print $2}'
RUN git --version
RUN curl --version
RUN wget --version
# Add user "nvm" as non-root user
RUN useradd -ms /bin/bash nvm
# Copy and set permission for nvm directory
COPY . /home/nvm/.nvm/
RUN chown nvm:nvm -R "/home/nvm/.nvm"
# Set sudoer for "nvm"
RUN echo 'nvm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# Switch to user "nvm" from now
USER nvm
# Create a script file sourced by both interactive and non-interactive bash shells
ENV BASH_ENV /home/nvm/.bash_env
RUN touch "$BASH_ENV"
RUN echo '. "$BASH_ENV"' >> "$HOME/.bashrc"
# nvm
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> "$BASH_ENV"
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "$BASH_ENV"
RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> "$BASH_ENV"
# nodejs and tools
RUN nvm install node
RUN npm install -g doctoc urchin eclint dockerfile_lint
RUN npm install --prefix "$HOME/.nvm/"
# Set WORKDIR to nvm directory
WORKDIR /home/nvm/.nvm
ENTRYPOINT ["/bin/bash"]

10
GOVERNANCE.md Normal file
View File

@ -0,0 +1,10 @@
# `nvm` Project Governance
## Maintainers
- [@ljharb](https://github.com/ljharb)
Maintainers are responsible for issue/PR triage, feature additions, maintenance, bugfixes, security fixes, releases, promoting existing contributors to maintainers, managing repo and CI configuration, etc.
## Contributors
Anyone who contributes code or content or time, via issues or pull requests or otherwise. Contributors do not have any additional permissions on the project.

View File

@ -1,6 +1,8 @@
The MIT License (MIT)
Copyright (c) 2010-2017 Tim Caswell
Copyright (c) 2010 Tim Caswell
Copyright (c) 2014 Jordan Harband
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
@ -18,4 +20,3 @@ 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.

View File

@ -40,10 +40,14 @@ list:
# Note that preexisting NVM_* variables are unset to avoid interfering with tests, except when running the Travis tests (where NVM_DIR must be passed in and the env. is assumed to be pristine).
.PHONY: $(SHELL_TARGETS)
$(SHELL_TARGETS):
@shell='$@'; shell=$${shell##*-}; which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \
printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \
[ -z "$$TRAVIS_BUILD_DIR" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \
for suite in $(TEST_SUITE); do $(URCHIN) -f -s $$shell test/$$suite || exit; done
@shell='$@'; shell=$${shell##*-}; \
which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \
printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \
[ -z "$$TRAVIS_BUILD_DIR" ] && [ -z "$$GITHUB_ACTIONS" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \
for suite in $(TEST_SUITE); do \
echo "Running test suite: $$suite"; \
$(URCHIN) -f -s $$shell test/$$suite || exit; \
done
# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS).
.PHONY: test
@ -72,14 +76,14 @@ _ensure-clean:
.PHONY: release
release: _ensure-tag _ensure-clean _ensure-current-version
@old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \
new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \
if printf "$$new_ver" | grep -q '^[0-9]'; then \
semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \
semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \
else \
new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \
fi; \
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \
git commit -m "v$$new_ver" $(VERSIONED_FILES) && \
git tag -a "v$$new_ver"
new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \
if printf "$$new_ver" | grep -q '^[0-9]'; then \
semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \
semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \
else \
new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \
fi; \
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
replace "$$old_ver" "$$new_ver" $(VERSIONED_FILES) && \
git commit -m "v$$new_ver" $(VERSIONED_FILES) && \
git tag -a "v$$new_ver"

49
PROJECT_CHARTER.md Normal file
View File

@ -0,0 +1,49 @@
# `nvm` Charter
nvm is a version manager for Node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and Windows WSL.
## Section 0: Guiding Principles
The `nvm` project is part of the [OpenJS Foundation][openjs foundation], which operates transparently, openly, collaboratively, and ethically. Project proposals, timelines, and status must not merely be open, but also easily visible to outsiders.
## Section 1: Scope
`nvm` is a node version manager, focused on making it easy to install and manage multiple Node.js versions. Any features related to managing the installation and removal of Node.js on any node-supported platform are potentially in scope.
## Section 2: Relationship with OpenJS Foundation CPC.
Technical leadership for the projects within the [OpenJS Foundation][openjs foundation] is delegated to the projects through their project charters by the [OpenJS Foundation Cross-Project Council](https://openjsf.org/about/governance/) (CPC). In the case of the `nvm` project, it is delegated to the [`nvm` Maintainers](README.md#maintainers) (the “Maintainers”). The OpenJS Foundation's business leadership is the Board of Directors (the “Board”).
This `nvm` Charter reflects a carefully constructed balanced role for the Maintainers and the CPC in the governance of the OpenJS Foundation. The charter amendment process is for the Maintainers to propose changes using simple majority of the full Maintainers, the proposed changes being subject to review and approval by the CPC. The CPC may additionally make amendments to the project charter at any time, though the CPC will not interfere with day-to-day discussions, votes or meetings of the Maintainers.
### 2.1 Other Formal Project Relationships
Section Intentionally Left Blank
## Section 3: `nvm`'s Maintainers Governing Body
`nvm` is governed by its [maintainers](README.md#maintainers).
## Section 4: Roles & Responsibilities
The roles and responsibilities of `nvm`'s Maintainers are described in [GOVERNANCE.md](./GOVERNANCE.md).
### Section 4.1 Project Operations & Management
Section Intentionally Left Blank
### Section 4.2: Decision-making, Voting, and/or Elections
Section Intentionally Left Blank
### Section 4.3: Other Project Roles
Section Intentionally Left Blank
## Section 5: Definitions
- *Contributors*: contribute code or other artifacts, but do not have the right to commit to the codebase. Contributors work with the projects maintainers to have code committed to the code base. A Contributor may be promoted to a Maintainer by the Maintainers. Contributors should rarely be encumbered by the Maintainers and never by the CPC or OpenJS Foundation Board.
- *Maintainers*: Contributors with any kind of decision-making authority in the project.
[openjs foundation]: https://openjsf.org

989
README.md

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,8 @@
This is a list of the primary features planned for `nvm`:
- [x] Rewriting installation code paths to support installing `io.js` and `node` `v4+` [from source](https://github.com/creationix/nvm/issues/1188).
- This will include [reusing previously downloaded tarballs](https://github.com/creationix/nvm/issues/1193) that match checksums, which is a nice performance and bandwith bonus.
- [ ] Adding opt-in environment variable support to list, download, and install `node` [release candidates](https://github.com/creationix/nvm/issues/779), and [nightly builds](https://github.com/creationix/nvm/issues/1053).
- [ ] [`nvm update`](https://github.com/creationix/nvm/issues/400): the ability to autoupdate `nvm` itself
- [ ] [v1.0.0](https://github.com/creationix/nvm/milestone/1), including updating the [nvm on npm](https://github.com/creationix/nvm/issues/304) to auto-install nvm properly
- [x] Rewriting installation code paths to support installing `io.js` and `node` `v4+` [from source](https://github.com/nvm-sh/nvm/issues/1188).
- This will include [reusing previously downloaded tarballs](https://github.com/nvm-sh/nvm/issues/1193) that match checksums, which is a nice performance and bandwidth bonus.
- [ ] Adding opt-in environment variable support to list, download, and install `node` [release candidates](https://github.com/nvm-sh/nvm/issues/779), and [nightly builds](https://github.com/nvm-sh/nvm/issues/1053).
- [ ] [`nvm update`](https://github.com/nvm-sh/nvm/issues/400): the ability to autoupdate `nvm` itself
- [ ] [v1.0.0](https://github.com/nvm-sh/nvm/milestone/1), including updating the [nvm on npm](https://github.com/nvm-sh/nvm/issues/304) to auto-install nvm properly

View File

@ -2,20 +2,19 @@
# bash completion for Node Version Manager (NVM)
if ! nvm &> /dev/null; then
return
if ! command -v nvm &> /dev/null; then
return
fi
__nvm_generate_completion()
{
__nvm_generate_completion() {
declare current_word
current_word="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=($(compgen -W "$1" -- "$current_word"))
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$1" -- "${current_word}"))
return 0
}
__nvm_commands ()
{
__nvm_commands() {
declare current_word
declare command
@ -25,61 +24,57 @@ __nvm_commands ()
help install uninstall use run exec
alias unalias reinstall-packages
current list ls list-remote ls-remote
cache clear-cache deactivate unload
install-latest-npm
cache deactivate unload
version version-remote which'
if [ ${#COMP_WORDS[@]} == 4 ]; then
if [ ${#COMP_WORDS[@]} == 4 ]; then
command="${COMP_WORDS[COMP_CWORD-2]}"
case "${command}" in
alias) __nvm_installed_nodes ;;
esac
command="${COMP_WORDS[COMP_CWORD - 2]}"
case "${command}" in
alias) __nvm_installed_nodes ;;
esac
else
else
case "${current_word}" in
-*) __nvm_options ;;
*) __nvm_generate_completion "$COMMANDS" ;;
esac
case "${current_word}" in
-*) __nvm_options ;;
*) __nvm_generate_completion "${COMMANDS}" ;;
esac
fi
fi
}
__nvm_options ()
{
__nvm_options() {
OPTIONS=''
__nvm_generate_completion "$OPTIONS"
__nvm_generate_completion "${OPTIONS}"
}
__nvm_installed_nodes ()
{
__nvm_installed_nodes() {
__nvm_generate_completion "$(nvm_ls) $(__nvm_aliases)"
}
__nvm_aliases ()
{
__nvm_aliases() {
declare aliases
aliases=""
if [ -d "$NVM_DIR/alias" ]; then
aliases="$(cd "$NVM_DIR/alias" && command find "$PWD" -type f | command sed "s:$PWD/::")"
if [ -d "${NVM_DIR}/alias" ]; then
aliases="$(command cd "${NVM_DIR}/alias" && command find "${PWD}" -type f | command sed "s:${PWD}/::")"
fi
echo "${aliases} node stable unstable iojs"
}
__nvm_alias ()
{
__nvm_alias() {
__nvm_generate_completion "$(__nvm_aliases)"
}
__nvm ()
{
__nvm() {
declare previous_word
previous_word="${COMP_WORDS[COMP_CWORD-1]}"
previous_word="${COMP_WORDS[COMP_CWORD - 1]}"
case "$previous_word" in
use|run|exec|ls|list|uninstall) __nvm_installed_nodes ;;
alias|unalias) __nvm_alias ;;
*) __nvm_commands ;;
case "${previous_word}" in
use | run | exec | ls | list | uninstall) __nvm_installed_nodes ;;
alias | unalias) __nvm_alias ;;
*) __nvm_commands ;;
esac
return 0
@ -89,8 +84,16 @@ __nvm ()
# 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
# First calling compinit (only if not called yet!)
# and then bashcompinit as mentioned by zsh man page.
if ! command -v compinit > /dev/null; then
autoload -U +X compinit && if [[ ${ZSH_DISABLE_COMPFIX-} = true ]]; then
compinit -u
else
compinit
fi
fi
autoload -U +X bashcompinit && bashcompinit
fi
complete -o default -F __nvm nvm

View File

@ -6,19 +6,41 @@ nvm_has() {
type "$1" > /dev/null 2>&1
}
nvm_echo() {
command printf %s\\n "$*" 2>/dev/null
}
if [ -z "${BASH_VERSION}" ] || [ -n "${ZSH_VERSION}" ]; then
# shellcheck disable=SC2016
nvm_echo >&2 'Error: the install instructions explicitly say to pipe the install script to `bash`; please follow them'
exit 1
fi
nvm_grep() {
GREP_OPTIONS='' command grep "$@"
}
nvm_default_install_dir() {
[ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm"
}
nvm_install_dir() {
printf %s "${NVM_DIR:-"$HOME/.nvm"}"
if [ -n "$NVM_DIR" ]; then
printf %s "${NVM_DIR}"
else
nvm_default_install_dir
fi
}
nvm_latest_version() {
echo "v0.33.2"
nvm_echo "v0.40.3"
}
nvm_profile_is_bash_or_zsh() {
local TEST_PROFILE
TEST_PROFILE="${1-}"
case "${TEST_PROFILE-}" in
*"/.bashrc" | *"/.bash_profile" | *"/.zshrc")
*"/.bashrc" | *"/.bash_profile" | *"/.zshrc" | *"/.zprofile")
return
;;
*)
@ -30,48 +52,72 @@ nvm_profile_is_bash_or_zsh() {
#
# Outputs the location to NVM depending on:
# * The availability of $NVM_SOURCE
# * The presence of $NVM_INSTALL_GITHUB_REPO
# * The method used ("script" or "git" in the script, defaults to "git")
# NVM_SOURCE always takes precedence unless the method is "script-nvm-exec"
#
nvm_source() {
local NVM_GITHUB_REPO
NVM_GITHUB_REPO="${NVM_INSTALL_GITHUB_REPO:-nvm-sh/nvm}"
if [ "${NVM_GITHUB_REPO}" != 'nvm-sh/nvm' ]; then
{ nvm_echo >&2 "$(cat)" ; } << EOF
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE REPO IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
The default repository for this install is \`nvm-sh/nvm\`,
but the environment variables \`\$NVM_INSTALL_GITHUB_REPO\` is
currently set to \`${NVM_GITHUB_REPO}\`.
If this is not intentional, interrupt this installation and
verify your environment variables.
EOF
fi
local NVM_VERSION
NVM_VERSION="${NVM_INSTALL_VERSION:-$(nvm_latest_version)}"
local NVM_METHOD
NVM_METHOD="$1"
local NVM_SOURCE_URL
NVM_SOURCE_URL="$NVM_SOURCE"
if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm-exec"
NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm-exec"
elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/bash_completion"
elif [ -z "$NVM_SOURCE_URL" ]; then
if [ "_$NVM_METHOD" = "_script" ]; then
NVM_SOURCE_URL="https://raw.githubusercontent.com/creationix/nvm/$(nvm_latest_version)/nvm.sh"
NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm.sh"
elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then
NVM_SOURCE_URL="https://github.com/creationix/nvm.git"
NVM_SOURCE_URL="https://github.com/${NVM_GITHUB_REPO}.git"
else
echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
nvm_echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"
return 1
fi
fi
echo "$NVM_SOURCE_URL"
nvm_echo "$NVM_SOURCE_URL"
}
#
# Node.js version to install
#
nvm_node_version() {
echo "$NODE_VERSION"
nvm_echo "$NODE_VERSION"
}
nvm_download() {
if nvm_has "curl"; then
curl --compressed -q "$@"
curl --fail --compressed -q "$@"
elif nvm_has "wget"; then
# Emulate curl with wget
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
-e 's/-L //' \
-e 's/--compressed //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
-e 's/--compressed //' \
-e 's/--fail //' \
-e 's/-L //' \
-e 's/-I /--server-response /' \
-e 's/-s /-q /' \
-e 's/-sS /-nv /' \
-e 's/-o /-O /' \
-e 's/-C - /-c /')
# shellcheck disable=SC2086
eval wget $ARGS
fi
@ -80,53 +126,76 @@ nvm_download() {
install_nvm_from_git() {
local INSTALL_DIR
INSTALL_DIR="$(nvm_install_dir)"
if [ -d "$INSTALL_DIR/.git" ]; then
echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
command printf "\r=> "
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself."
local NVM_VERSION
NVM_VERSION="${NVM_INSTALL_VERSION:-$(nvm_latest_version)}"
if [ -n "${NVM_INSTALL_VERSION:-}" ]; then
# Check if version is an existing ref
if command git ls-remote "$(nvm_source "git")" "$NVM_VERSION" | nvm_grep -q "$NVM_VERSION" ; then
:
# Check if version is an existing changeset
elif ! nvm_download -o /dev/null "$(nvm_source "script-nvm-exec")"; then
nvm_echo >&2 "Failed to find '$NVM_VERSION' version."
exit 1
}
fi
fi
local fetch_error
if [ -d "$INSTALL_DIR/.git" ]; then
# Updating repo
nvm_echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
command printf '\r=> '
fetch_error="Failed to update nvm with $NVM_VERSION, run 'git fetch' in $INSTALL_DIR yourself."
else
# Cloning to $INSTALL_DIR
echo "=> Downloading nvm from git to '$INSTALL_DIR'"
command printf "\r=> "
fetch_error="Failed to fetch origin with $NVM_VERSION. Please report this!"
nvm_echo "=> Downloading nvm from git to '$INSTALL_DIR'"
command printf '\r=> '
mkdir -p "${INSTALL_DIR}"
if [ "$(ls -A "${INSTALL_DIR}")" ]; then
# Initializing repo
command git init "${INSTALL_DIR}" || {
echo >&2 'Failed to initialize nvm repo. Please report this!'
nvm_echo >&2 'Failed to initialize nvm repo. Please report this!'
exit 2
}
command git --git-dir="${INSTALL_DIR}/.git" remote add origin "$(nvm_source)" 2> /dev/null \
|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url origin "$(nvm_source)" || {
echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
exit 2
}
command git --git-dir="${INSTALL_DIR}/.git" fetch origin --tags || {
echo >&2 'Failed to fetch origin with tags. Please report this!'
nvm_echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
exit 2
}
else
command git clone "$(nvm_source)" "${INSTALL_DIR}" || {
echo >&2 'Failed to clone nvm repo. Please report this!'
# Cloning repo
command git clone "$(nvm_source)" --depth=1 "${INSTALL_DIR}" || {
nvm_echo >&2 'Failed to clone nvm repo. Please report this!'
exit 2
}
fi
fi
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet "$(nvm_latest_version)"
if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
# Try to fetch tag
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$NVM_VERSION" --depth=1 2>/dev/null; then
:
# Fetch given version
elif ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin "$NVM_VERSION" --depth=1; then
nvm_echo >&2 "$fetch_error"
exit 1
fi
command git -c advice.detachedHead=false --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet FETCH_HEAD || {
nvm_echo >&2 "Failed to checkout the given version $NVM_VERSION. Please report this!"
exit 2
}
if [ -n "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then
if command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then
command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
else
echo >&2 "Your version of git is out of date. Please update it!"
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1
nvm_echo >&2 "Your version of git is out of date. Please update it!"
command git --no-pager --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch -D master >/dev/null 2>&1
fi
fi
echo "=> Compressing and cleaning up git repository"
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --aggressive --prune=now ; then
echo >&2 "Your version of git is out of date. Please update it!"
nvm_echo "=> Compressing and cleaning up git repository"
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" reflog expire --expire=now --all; then
nvm_echo >&2 "Your version of git is out of date. Please update it!"
fi
if ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" gc --auto --aggressive --prune=now ; then
nvm_echo >&2 "Your version of git is out of date. Please update it!"
fi
return
}
@ -135,22 +204,22 @@ install_nvm_from_git() {
# Automatically install Node.js
#
nvm_install_node() {
local NODE_VERSION
NODE_VERSION="$(nvm_node_version)"
local NODE_VERSION_LOCAL
NODE_VERSION_LOCAL="$(nvm_node_version)"
if [ -z "$NODE_VERSION" ]; then
if [ -z "$NODE_VERSION_LOCAL" ]; then
return 0
fi
echo "=> Installing Node.js version $NODE_VERSION"
nvm install "$NODE_VERSION"
nvm_echo "=> Installing Node.js version $NODE_VERSION_LOCAL"
nvm install "$NODE_VERSION_LOCAL"
local CURRENT_NVM_NODE
CURRENT_NVM_NODE="$(nvm_version current)"
if [ "$(nvm_version "$NODE_VERSION")" == "$CURRENT_NVM_NODE" ]; then
echo "=> Node.js version $NODE_VERSION has been successfully installed"
if [ "$(nvm_version "$NODE_VERSION_LOCAL")" == "$CURRENT_NVM_NODE" ]; then
nvm_echo "=> Node.js version $NODE_VERSION_LOCAL has been successfully installed"
else
echo >&2 "Failed to install Node.js $NODE_VERSION"
nvm_echo >&2 "Failed to install Node.js $NODE_VERSION_LOCAL"
fi
}
@ -158,31 +227,37 @@ install_nvm_as_script() {
local INSTALL_DIR
INSTALL_DIR="$(nvm_install_dir)"
local NVM_SOURCE_LOCAL
NVM_SOURCE_LOCAL=$(nvm_source script)
NVM_SOURCE_LOCAL="$(nvm_source script)"
local NVM_EXEC_SOURCE
NVM_EXEC_SOURCE=$(nvm_source script-nvm-exec)
NVM_EXEC_SOURCE="$(nvm_source script-nvm-exec)"
local NVM_BASH_COMPLETION_SOURCE
NVM_BASH_COMPLETION_SOURCE="$(nvm_source script-nvm-bash-completion)"
# Downloading to $INSTALL_DIR
mkdir -p "$INSTALL_DIR"
if [ -f "$INSTALL_DIR/nvm.sh" ]; then
echo "=> nvm is already installed in $INSTALL_DIR, trying to update the script"
nvm_echo "=> nvm is already installed in $INSTALL_DIR, trying to update the script"
else
echo "=> Downloading nvm as script to '$INSTALL_DIR'"
nvm_echo "=> Downloading nvm as script to '$INSTALL_DIR'"
fi
nvm_download -s "$NVM_SOURCE_LOCAL" -o "$INSTALL_DIR/nvm.sh" || {
echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"
nvm_echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"
return 1
} &
nvm_download -s "$NVM_EXEC_SOURCE" -o "$INSTALL_DIR/nvm-exec" || {
echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
nvm_echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
return 2
} &
for job in $(jobs -p | sort)
nvm_download -s "$NVM_BASH_COMPLETION_SOURCE" -o "$INSTALL_DIR/bash_completion" || {
nvm_echo >&2 "Failed to download '$NVM_BASH_COMPLETION_SOURCE'"
return 2
} &
for job in $(jobs -p | command sort)
do
wait "$job" || return $?
done
chmod a+x "$INSTALL_DIR/nvm-exec" || {
echo >&2 "Failed to mark '$INSTALL_DIR/nvm-exec' as executable"
nvm_echo >&2 "Failed to mark '$INSTALL_DIR/nvm-exec' as executable"
return 3
}
}
@ -191,7 +266,7 @@ nvm_try_profile() {
if [ -z "${1-}" ] || [ ! -f "${1}" ]; then
return 1
fi
echo "${1}"
nvm_echo "${1}"
}
#
@ -201,37 +276,44 @@ nvm_try_profile() {
# Otherwise, an empty string is returned
#
nvm_detect_profile() {
if [ "${PROFILE-}" = '/dev/null' ]; then
# the user has specifically requested NOT to have nvm touch their profile
return
fi
if [ -n "${PROFILE}" ] && [ -f "${PROFILE}" ]; then
echo "${PROFILE}"
nvm_echo "${PROFILE}"
return
fi
local DETECTED_PROFILE
DETECTED_PROFILE=''
local SHELLTYPE
SHELLTYPE="$(basename "/$SHELL")"
if [ "$SHELLTYPE" = "bash" ]; then
if [ "${SHELL#*bash}" != "$SHELL" ]; then
if [ -f "$HOME/.bashrc" ]; then
DETECTED_PROFILE="$HOME/.bashrc"
elif [ -f "$HOME/.bash_profile" ]; then
DETECTED_PROFILE="$HOME/.bash_profile"
fi
elif [ "$SHELLTYPE" = "zsh" ]; then
DETECTED_PROFILE="$HOME/.zshrc"
elif [ "${SHELL#*zsh}" != "$SHELL" ]; then
if [ -f "${ZDOTDIR:-${HOME}}/.zshrc" ]; then
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zshrc"
elif [ -f "${ZDOTDIR:-${HOME}}/.zprofile" ]; then
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zprofile"
fi
fi
if [ -z "$DETECTED_PROFILE" ]; then
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zshrc"
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc"
do
if DETECTED_PROFILE="$(nvm_try_profile "${HOME}/${EACH_PROFILE}")"; then
if DETECTED_PROFILE="$(nvm_try_profile "${ZDOTDIR:-${HOME}}/${EACH_PROFILE}")"; then
break
fi
done
fi
if [ ! -z "$DETECTED_PROFILE" ]; then
echo "$DETECTED_PROFILE"
if [ -n "$DETECTED_PROFILE" ]; then
nvm_echo "$DETECTED_PROFILE"
fi
}
@ -240,7 +322,9 @@ nvm_detect_profile() {
# Node, and warn them if so.
#
nvm_check_global_modules() {
command -v npm >/dev/null 2>&1 || return 0
local NPM_COMMAND
NPM_COMMAND="$(command -v npm 2>/dev/null)" || return 0
[ -n "${NVM_DIR}" ] && [ -z "${NPM_COMMAND%%"$NVM_DIR"/*}" ] && return 0
local NPM_VERSION
NPM_VERSION="$(npm --version)"
@ -257,94 +341,124 @@ nvm_check_global_modules() {
MODULE_COUNT="$(
command printf %s\\n "$NPM_GLOBAL_MODULES" |
command sed -ne '1!p' | # Remove the first line
wc -l | tr -d ' ' # Count entries
wc -l | command tr -d ' ' # Count entries
)"
if [ "${MODULE_COUNT}" != '0' ]; then
# shellcheck disable=SC2016
echo '=> You currently have modules installed globally with `npm`. These will no'
nvm_echo '=> You currently have modules installed globally with `npm`. These will no'
# shellcheck disable=SC2016
echo '=> longer be linked to the active version of Node when you install a new node'
nvm_echo '=> longer be linked to the active version of Node when you install a new node'
# shellcheck disable=SC2016
echo '=> with `nvm`; and they may (depending on how you construct your `$PATH`)'
nvm_echo '=> with `nvm`; and they may (depending on how you construct your `$PATH`)'
# shellcheck disable=SC2016
echo '=> override the binaries of modules installed with `nvm`:'
echo
nvm_echo '=> override the binaries of modules installed with `nvm`:'
nvm_echo
command printf %s\\n "$NPM_GLOBAL_MODULES"
echo '=> If you wish to uninstall them at a later point (or re-install them under your'
nvm_echo '=> If you wish to uninstall them at a later point (or re-install them under your'
# shellcheck disable=SC2016
echo '=> `nvm` Nodes), you can remove them from the system Node as follows:'
echo
echo ' $ nvm use system'
echo ' $ npm uninstall -g a_module'
echo
nvm_echo '=> `nvm` node installs), you can remove them from the system Node as follows:'
nvm_echo
nvm_echo ' $ nvm use system'
nvm_echo ' $ npm uninstall -g a_module'
nvm_echo
fi
}
nvm_do_install() {
if [ -n "${NVM_DIR-}" ] && ! [ -d "${NVM_DIR}" ]; then
if [ -e "${NVM_DIR}" ]; then
nvm_echo >&2 "File \"${NVM_DIR}\" has the same name as installation directory."
exit 1
fi
if [ "${NVM_DIR}" = "$(nvm_default_install_dir)" ]; then
mkdir "${NVM_DIR}"
else
nvm_echo >&2 "You have \$NVM_DIR set to \"${NVM_DIR}\", but that directory does not exist. Check your profile files and environment."
exit 1
fi
fi
# Disable the optional which check, https://www.shellcheck.net/wiki/SC2230
# shellcheck disable=SC2230
if nvm_has xcode-select && [ "$(xcode-select -p >/dev/null 2>/dev/null ; echo $?)" = '2' ] && [ "$(which git)" = '/usr/bin/git' ] && [ "$(which curl)" = '/usr/bin/curl' ]; then
nvm_echo >&2 'You may be on a Mac, and need to install the Xcode Command Line Developer Tools.'
# shellcheck disable=SC2016
nvm_echo >&2 'If so, run `xcode-select --install` and try again. If not, please report this!'
exit 1
fi
if [ -z "${METHOD}" ]; then
# Autodetect install method
if nvm_has git; then
install_nvm_from_git
elif nvm_has nvm_download; then
elif nvm_has curl || nvm_has wget; then
install_nvm_as_script
else
echo >&2 'You need git, curl, or wget to install nvm'
nvm_echo >&2 'You need git, curl, or wget to install nvm'
exit 1
fi
elif [ "${METHOD}" = 'git' ]; then
if ! nvm_has git; then
echo >&2 "You need git to install nvm"
nvm_echo >&2 "You need git to install nvm"
exit 1
fi
install_nvm_from_git
elif [ "${METHOD}" = 'script' ]; then
if ! nvm_has nvm_download; then
echo >&2 "You need curl or wget to install nvm"
if ! nvm_has curl && ! nvm_has wget; then
nvm_echo >&2 "You need curl or wget to install nvm"
exit 1
fi
install_nvm_as_script
else
nvm_echo >&2 "The environment variable \$METHOD is set to \"${METHOD}\", which is not recognized as a valid installation method."
exit 1
fi
echo
nvm_echo
local NVM_PROFILE
NVM_PROFILE="$(nvm_detect_profile)"
local PROFILE_INSTALL_DIR
PROFILE_INSTALL_DIR="$(nvm_install_dir| sed "s:^$HOME:\$HOME:")"
PROFILE_INSTALL_DIR="$(nvm_install_dir | command sed "s:^$HOME:\$HOME:")"
SOURCE_STR="\nexport NVM_DIR=\"${PROFILE_INSTALL_DIR}\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" # This loads nvm\n"
COMPLETION_STR="[ -s \"\$NVM_DIR/bash_completion\" ] && \\. \"\$NVM_DIR/bash_completion\" # This loads nvm bash_completion\n"
SOURCE_STR="\\nexport NVM_DIR=\"${PROFILE_INSTALL_DIR}\"\\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" # This loads nvm\\n"
# shellcheck disable=SC2016
COMPLETION_STR='[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion\n'
BASH_OR_ZSH=false
if [ -z "${NVM_PROFILE-}" ] ; then
echo "=> Profile not found. Tried ${NVM_PROFILE} (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
echo "=> Create one of them and run this script again"
echo "=> Create it (touch ${NVM_PROFILE}) and run this script again"
echo " OR"
echo "=> Append the following lines to the correct file yourself:"
local TRIED_PROFILE
if [ -n "${PROFILE}" ]; then
TRIED_PROFILE="${NVM_PROFILE} (as defined in \$PROFILE), "
fi
nvm_echo "=> Profile not found. Tried ${TRIED_PROFILE-}~/.bashrc, ~/.bash_profile, ~/.zprofile, ~/.zshrc, and ~/.profile."
nvm_echo "=> Create one of them and run this script again"
nvm_echo " OR"
nvm_echo "=> Append the following lines to the correct file yourself:"
command printf "${SOURCE_STR}"
nvm_echo
else
if nvm_profile_is_bash_or_zsh "${NVM_PROFILE-}"; then
BASH_OR_ZSH=true
fi
if ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; then
echo "=> Appending nvm source string to $NVM_PROFILE"
nvm_echo "=> Appending nvm source string to $NVM_PROFILE"
command printf "${SOURCE_STR}" >> "$NVM_PROFILE"
else
echo "=> nvm source string already in ${NVM_PROFILE}"
nvm_echo "=> nvm source string already in ${NVM_PROFILE}"
fi
# shellcheck disable=SC2016
if ${BASH_OR_ZSH} && ! command grep -qc '$NVM_DIR/bash_completion' "$NVM_PROFILE"; then
echo "=> Appending bash_completion source string to $NVM_PROFILE"
nvm_echo "=> Appending bash_completion source string to $NVM_PROFILE"
command printf "$COMPLETION_STR" >> "$NVM_PROFILE"
else
echo "=> bash_completion source string already in ${NVM_PROFILE}"
nvm_echo "=> bash_completion source string already in ${NVM_PROFILE}"
fi
fi
if ${BASH_OR_ZSH} && [ -z "${NVM_PROFILE-}" ] ; then
echo "=> Please also append the following lines to the if you are using bash/zsh shell:"
nvm_echo "=> Please also append the following lines to the if you are using bash/zsh shell:"
command printf "${COMPLETION_STR}"
fi
@ -358,7 +472,7 @@ nvm_do_install() {
nvm_reset
echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
nvm_echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
command printf "${SOURCE_STR}"
if ${BASH_OR_ZSH} ; then
command printf "${COMPLETION_STR}"
@ -373,7 +487,7 @@ nvm_reset() {
unset -f nvm_has nvm_install_dir nvm_latest_version nvm_profile_is_bash_or_zsh \
nvm_source nvm_node_version nvm_download install_nvm_from_git nvm_install_node \
install_nvm_as_script nvm_try_profile nvm_detect_profile nvm_check_global_modules \
nvm_do_install nvm_reset
nvm_do_install nvm_reset nvm_default_install_dir nvm_grep
}
[ "_$NVM_ENV" = "_testing" ] || nvm_do_install

View File

@ -2,7 +2,9 @@
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# shellcheck disable=SC1090
unset NVM_CD_FLAGS
# shellcheck disable=SC1090,SC1091
\. "$DIR/nvm.sh" --no-use
if [ -n "$NODE_VERSION" ]; then

3132
nvm.sh Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +1,32 @@
{
"name": "nvm",
"version": "0.33.2",
"version": "0.40.3",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": {
"test": "test"
},
"scripts": {
"test": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make test-$shell",
"test/fast": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=fast test-$shell",
"test/fast": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); env -i TERM=\"$TERM\" bash -lc \"make TEST_SUITE=fast test-$shell\"",
"test/slow": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=slow test-$shell",
"test/install_script": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=install_script test-$shell",
"test/installation": "npm run --silent test/installation/node && npm run --silent test/installation/iojs",
"test/installation/node": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation_node test-$shell",
"test/installation/iojs": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation_iojs test-$shell",
"test/sourcing": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=sourcing test-$shell",
"doctoc": "doctoc --title='## Table of Contents' --github README.md"
"test:check-exec": "(IFS=$'\\n'; for file in $(git ls-files test); do if [ ! -x \"$file\" ] && [[ \"$file\" != *.* ]] && [[ \"$file\" != test/fixtures/* ]]; then echo \"$file\"; fi; done) | tee /dev/stderr | awk 'END {if (NR > 0) exit 1}'",
"test:check-nonexec": "(IFS=$'\\n'; for file in $(git ls-files test); do if [ -x \"$file\" ] && [ ! -d \"$file\" ] && { [[ \"$file\" =~ '\\.(json|txt|sh|js|log)$' ]] || [[ \"$file\" =~ '^test/(mocks|fixtures)/.*' ]]; }; then echo \"$file\"; fi; done) | tee /dev/stderr | awk 'END {if (NR > 0) exit 1}'",
"doctoc": "doctoc --title='## Table of Contents' --github README.md",
"predoctoc:check": "cp README.md v-README.md.orig && npm run doctoc",
"doctoc:check": "diff -q README.md v-README.md.orig",
"postdoctoc:check": "mv v-README.md.orig README.md",
"eclint": "eclint check $(git ls-tree --name-only HEAD | xargs)",
"dockerfile_lint": "dockerfile_lint",
"markdown-link-check": "git ls-files | command grep -E '\\.md$' | xargs -n 1 markdown-link-check -p"
},
"repository": {
"type": "git",
"url": "git://github.com/creationix/nvm.git"
"url": "git://github.com/nvm-sh/nvm.git"
},
"keywords": [
"nvm",
@ -30,13 +38,16 @@
"author": "Tim Caswell <tim@creationix.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/creationix/nvm/issues"
"url": "https://github.com/nvm-sh/nvm/issues"
},
"homepage": "https://github.com/creationix/nvm",
"homepage": "https://github.com/nvm-sh/nvm",
"devDependencies": {
"replace": "^0.3.0",
"semver": "^5.0.1",
"urchin": "^0.0.5",
"doctoc": "^1.2.0"
"dockerfile_lint": "^0.3.4",
"doctoc": "^2.2.1",
"eclint": "^2.8.1",
"markdown-link-check": "^3.13.7",
"replace": "^1.2.2",
"semver": "^7.7.1",
"urchin": "^0.0.5"
}
}

52
rename_test.sh Executable file
View File

@ -0,0 +1,52 @@
#! /usr/bin/env bash
find_name(){
find test -name "*[\\/:\*\?\"<>\|]*" -o -name "*."
}
check_name() {
if [ "$(find_name | wc -l)" != "0" ]; then
printf '%s\n\n' "The following filenames contain unwanted characters:"
find_name
printf '\n%s\n%s\n' "Please run ./rename_test.sh" "If the problem persist, please open an issue."
exit 1
else
echo "Ok"
fi
}
rename_test() {
local filename
local new_filename
while read -r filename; do
# Even though it looks < and > are replaced by the same < and >, the latters are not ASCII code
# If you check with 'cat -v rename_test.sh' you would see 's/</M-KM-^B/g' and 's/>/M-KM-^C/g'
# M-KM-^B -> U+02C2
# M-KM-^C -> U+02C3
new_filename=$(echo "$filename" | sed -r \
-e "s/\"/'/g" \
-e 's/</˂/g' \
-e 's/>/˃/g' \
-e 's/^(.*)\.$/\1/'
)
printf '%s\n%s\n\n' "$filename" "$new_filename"
[ "$filename" != "$new_filename" ] && git mv "$filename" "$new_filename"
done < <(find_name)
if [ "$(find_name | wc -l)" != "0" ]; then
echo "Still some files to treat:"
find_name
else
echo "Done"
fi
}
main() {
if [ "$1" = "--check" ]; then
check_name
else
rename_test
fi
}
main "$@"

View File

@ -29,8 +29,16 @@ make_fake_node() {
VERSION="${1-}"
[ -n "${VERSION}" ] || return 1
local FORMATTED_VERSION
FORMATTED_VERSION="$(nvm_format_version "${VERSION}")"
local BIN_PATH
BIN_PATH="$(nvm_version_path "${VERSION}")/bin"
BIN_PATH="$(nvm_version_path "${FORMATTED_VERSION}")/bin"
[ "${BIN_PATH}" != "/bin" ] || {
echo >&2 'nvm_version_path was empty'
return 5
}
mkdir -p "${BIN_PATH}" || {
echo >&2 'unable to make bin dir'
return 2
@ -40,6 +48,11 @@ make_fake_node() {
echo >&2 'unable to make fake node bin'
return 3
}
nvm_is_version_installed "${FORMATTED_VERSION}" || {
echo >&2 'fake node is not installed'
return 4
}
}
make_fake_iojs() {
@ -47,8 +60,16 @@ make_fake_iojs() {
VERSION="${1-}"
[ -n "${VERSION}" ] || return 1
local FORMATTED_VERSION
FORMATTED_VERSION="$(nvm_format_version "iojs-${VERSION}")"
local BIN_PATH
BIN_PATH="$(nvm_version_path "iojs-${VERSION}")/bin"
BIN_PATH="$(nvm_version_path "${FORMATTED_VERSION}")/bin"
[ "${BIN_PATH}" != "/bin" ] || {
echo >&2 'nvm_version_path was empty'
return 5
}
mkdir -p "${BIN_PATH}" || {
echo >&2 'unable to make bin dir'
return 2
@ -62,6 +83,11 @@ make_fake_iojs() {
echo >&2 'unable to make fake iojs bin'
return 3
}
nvm_is_version_installed "${FORMATTED_VERSION}" || {
echo >&2 'fake iojs is not installed'
return 4
}
}
watch() {
@ -75,3 +101,147 @@ watch() {
kill %2;
return $EXIT_CODE
}
# JSON parsing from https://gist.github.com/assaf/ee377a186371e2e269a7
nvm_json_throw() {
nvm_err "$*"
exit 1
}
nvm_json_awk_egrep() {
local pattern_string
pattern_string="${1}"
awk '{
while ($0) {
start=match($0, pattern);
token=substr($0, start, RLENGTH);
print token;
$0=substr($0, start+RLENGTH);
}
}' "pattern=${pattern_string}"
}
nvm_json_tokenize() {
local GREP
GREP='grep -Eao'
local ESCAPE
local CHAR
# if echo "test string" | grep -Eo "test" > /dev/null 2>&1; then
# ESCAPE='(\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
# CHAR='[^[:cntrl:]"\\]'
# else
GREP=nvm_json_awk_egrep
ESCAPE='(\\\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'
CHAR='[^[:cntrl:]"\\\\]'
# fi
local STRING
STRING="\"${CHAR}*(${ESCAPE}${CHAR}*)*\""
local NUMBER
NUMBER='-?(0|[1-9][0-9]*)([.][0-9]*)?([eE][+-]?[0-9]*)?'
local KEYWORD
KEYWORD='null|false|true'
local SPACE
SPACE='[[:space:]]+'
$GREP "${STRING}|${NUMBER}|${KEYWORD}|${SPACE}|." | TERM=dumb grep -Ev "^${SPACE}$"
}
_json_parse_array() {
local index=0
local ary=''
read -r token
case "$token" in
']') ;;
*)
while :; do
_json_parse_value "${1}" "${index}"
index=$((index+1))
ary="${ary}${value}"
read -r token
case "${token}" in
']') break ;;
',') ary="${ary}," ;;
*) nvm_json_throw "EXPECTED , or ] GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
:
}
_json_parse_object() {
local key
local obj=''
read -r token
case "$token" in
'}') ;;
*)
while :; do
case "${token}" in
'"'*'"') key="${token}" ;;
*) nvm_json_throw "EXPECTED string GOT ${token:-EOF}" ;;
esac
read -r token
case "${token}" in
':') ;;
*) nvm_json_throw "EXPECTED : GOT ${token:-EOF}" ;;
esac
read -r token
_json_parse_value "${1}" "${key}"
obj="${obj}${key}:${value}"
read -r token
case "${token}" in
'}') break ;;
',') obj="${obj}," ;;
*) nvm_json_throw "EXPECTED , or } GOT ${token:-EOF}" ;;
esac
read -r token
done
;;
esac
:
}
_json_parse_value() {
local jpath="${1:+$1,}$2"
local isleaf=0
local isempty=0
local print=0
case "$token" in
'{') _json_parse_object "${jpath}" ;;
'[') _json_parse_array "${jpath}" ;;
# At this point, the only valid single-character tokens are digits.
''|[!0-9]) nvm_json_throw "EXPECTED value GOT >${token:-EOF}<" ;;
*)
value=$token
isleaf=1
[ "${value}" = '""' ] && isempty=1
;;
esac
[ "${value}" = '' ] && return
[ "${isleaf}" -eq 1 ] && [ $isempty -eq 0 ] && print=1
[ "${print}" -eq 1 ] && printf "[%s]\t%s\n" "${jpath}" "${value}"
:
}
_json_parse() {
read -r token
_json_parse_value
read -r token
case "${token}" in
'') ;;
*) nvm_json_throw "EXPECTED EOF GOT >${token}<" ;;
esac
}
nvm_json_extract() {
nvm_json_tokenize | _json_parse | grep -e "${1}" | awk '{print $2 $3}'
}

View File

@ -0,0 +1,20 @@
#!/bin/sh
die() { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../../.. && pwd)"
\. "${NVM_DIR}/nvm.sh"
\. ../../common.sh
echo "
v0.0.1
" > ../../../alias/test-blank-lines
EXPECTED='v0.0.1'
ACTUAL="$(nvm_alias test-blank-lines)"
EXIT_CODE="$(nvm_alias test-blank-lines 2>&1 >/dev/null; echo $?)"
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
[ "${EXIT_CODE}" = '0' ] || die "expected exit code 0, got ${EXIT_CODE}"

View File

@ -0,0 +1,26 @@
#!/bin/sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }
OUTPUT="$(nvm alias foo#bar baz 2>&1)"
EXPECTED_OUTPUT="Aliases with a comment delimiter (#) are not supported."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to create an alias with a hash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
EXIT_CODE="$(nvm alias foo#bar baz >/dev/null 2>&1 ; echo $?)"
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias with a hash should fail with code 1, got '$EXIT_CODE'"
OUTPUT="$(nvm alias foo# baz 2>&1)"
EXPECTED_OUTPUT="Aliases with a comment delimiter (#) are not supported."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to create an alias ending with a hash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
EXIT_CODE="$(nvm alias foo# baz >/dev/null 2>&1 ; echo $?)"
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias ending with a hash should fail with code 1, got '$EXIT_CODE'"
OUTPUT="$(nvm alias \#bar baz 2>&1)"
EXPECTED_OUTPUT="Aliases with a comment delimiter (#) are not supported."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to create an alias starting with a hash should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
EXIT_CODE="$(nvm alias \#bar baz >/dev/null 2>&1 ; echo $?)"
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias starting with a hash should fail with code 1, got '$EXIT_CODE'"

View File

@ -24,4 +24,3 @@ EXPECTED_OUTPUT="Aliases in subdirectories are not supported."
EXIT_CODE="$(nvm alias /bar baz >/dev/null 2>&1 ; echo $?)"
[ "$EXIT_CODE" = "1" ] || die "trying to create an alias starting with a slash should fail with code 1, got '$EXIT_CODE'"

View File

@ -0,0 +1,17 @@
#!/bin/sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }
OUTPUT="$(nvm unalias node 2>&1)"
EXPECTED_OUTPUT="node is a default (built-in) alias and cannot be deleted."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
nvm alias node stable || die '`nvm alias node stable` failed'
nvm unalias node || die '`nvm unalias node` failed'
OUTPUT="$(nvm unalias node 2>&1)"
EXPECTED_OUTPUT="node is a default (built-in) alias and cannot be deleted."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"

View File

@ -0,0 +1,25 @@
#!/bin/sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }
OUTPUT="$(nvm unalias node 2>&1)"
EXPECTED_OUTPUT="node is a default (built-in) alias and cannot be deleted."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
OUTPUT="$(nvm unalias stable 2>&1)"
EXPECTED_OUTPUT="stable is a default (built-in) alias and cannot be deleted."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
OUTPUT="$(nvm unalias unstable 2>&1)"
EXPECTED_OUTPUT="unstable is a default (built-in) alias and cannot be deleted."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
OUTPUT="$(nvm unalias iojs 2>&1)"
EXPECTED_OUTPUT="iojs is a default (built-in) alias and cannot be deleted."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"
OUTPUT="$(nvm unalias system 2>&1)"
EXPECTED_OUTPUT="system is a default (built-in) alias and cannot be deleted."
[ "$OUTPUT" = "$EXPECTED_OUTPUT" ] || die "trying to remove a built-in alias should fail with '$EXPECTED_OUTPUT', got '$OUTPUT'"

View File

@ -24,4 +24,3 @@ EXPECTED_OUTPUT="Aliases in subdirectories are not supported."
EXIT_CODE="$(nvm unalias /bar >/dev/null 2>&1 ; echo $?)"
[ "$EXIT_CODE" = "1" ] || die "trying to remove an alias starting with a slash should fail with code 1, got '$EXIT_CODE'"

View File

@ -24,4 +24,3 @@ EXPECTED_IOJS="$(nvm_print_implicit_alias local iojs)"
IOJS_VERSION="$(nvm_version "$EXPECTED_IOJS")"
echo "$NVM_ALIAS_OUTPUT" | \grep -F "iojs -> $EXPECTED_IOJS (-> $IOJS_VERSION) (default)" \
|| die "nvm alias did not contain the default local iojs version; got '$NVM_ALIAS_OUTPUT'"

View File

@ -14,9 +14,9 @@ cleanup () {
rm -rf "${NVM_DIR}/versions/io.js/v0.2.1"
}
mkdir "${NVM_DIR}/v0.8.1"
mkdir "${NVM_DIR}/v0.9.1"
mkdir -p "${NVM_DIR}/versions/io.js/v0.2.1"
make_fake_node v0.8.1
make_fake_node v0.9.1
make_fake_iojs v0.2.1
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"

View File

@ -7,4 +7,3 @@ echo three > ../../../../alias/two
echo one > ../../../../alias/three
echo two > ../../../../alias/four

View File

@ -7,4 +7,3 @@ rm -f ../../../../alias/two
rm -f ../../../../alias/three
rm -f ../../../../alias/four

View File

@ -0,0 +1,22 @@
#!/bin/sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }
set -e
nvm_get_colors(){
echo "0;95m"
}
nvm_alias_path() {
nvm_echo "../../../alias"
}
OUTPUT=$(command printf %b $(nvm_list_aliases test-stable-1) | awk '{ print substr($0, 1, 19); }')
EXPECTED_OUTPUT=$(command printf %b "\033[0;95mtest-stable-1" | awk '{ print substr($0, 1, 19); }')
echo "\033[0m"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "nvm_list_aliases did not call nvm_get_colors. Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"

View File

@ -0,0 +1,31 @@
#!/bin/sh
\. ../../../nvm.sh
die () {
echo "$@"
exit 1
}
set -e
MOCKS_DIR="../Unit tests/mocks"
# sample output at the time the test was written
TAB_PATH="$MOCKS_DIR/nodejs.org-dist-index.tab"
nvm_download() {
cat "$TAB_PATH"
}
nvm_alias_path() {
nvm_echo "../../../alias"
}
nvm ls-remote >/dev/null || die 'nvm ls-remote (to populate LTS aliases) failed'
EXPECTED_OUTPUT="$(cat "$MOCKS_DIR/lts-star.txt")"
STDOUT_OUTPUT="$(nvm_list_aliases "lts/*")"
STDERR_OUTPUT="$(nvm_list_aliases "lts/*" 2>&1 >/dev/null)"
[ -z "${STDERR_OUTPUT}" ] || die "expected no stderr output, got >${STDERR_OUTPUT}<"
[ "${STDOUT_OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected ${EXPECTED_OUTPUT}, got >${STDOUT_OUTPUT}<"

View File

@ -0,0 +1,21 @@
#!/bin/sh
\. ../../../nvm.sh
die () {
mv "$(nvm_alias_path)/_lts.bak" "$(nvm_alias_path)/lts"
echo "$@"
exit 1
}
set -e
nvm_alias_path() {
nvm_echo "../../../alias"
}
mv "$(nvm_alias_path)/lts" "$(nvm_alias_path)/_lts.bak"
STDERR_OUTPUT="$(nvm_list_aliases 2>&1 >/dev/null)"
[ -z "${STDERR_OUTPUT}" ] || die "expected no stderr output, got >${STDERR_OUTPUT}<"

View File

@ -0,0 +1,28 @@
#!/bin/sh
\. ../../../nvm.sh
die () {
# echo "$@" ;
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
exit 1
}
set -e
nvm_get_colors(){
echo "0;95m"
}
# nvm_print_alias_path call nvm_print_formatted_alias which calls nvm_get-colors
# the output of nvm_print_alias_path uses the color code returned by nvm_get_colors (redefined above)
NVM_ALIAS_DIR='../../../alias'
OUTPUT=$(command printf %b $(nvm_print_alias_path "$NVM_ALIAS_DIR" "$NVM_ALIAS_DIR"/test-stable-1) | awk '{ print substr($0, 1, 24); }')
EXPECTED_OUTPUT=$(command printf %b "\033[0;95mtest-stable-1\033[0m")
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
set +e

View File

@ -0,0 +1,21 @@
#!/bin/sh
\. ../../../nvm.sh
die () {
echo "Expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
exit 1
}
set -e
# # # expecting in red and two grays:
OUTPUT=$(echo $(nvm_print_formatted_alias fakealias fakedest) | awk '{ print substr($0, 1, 21); }')
EXPECTED_OUTPUT="$(command printf %b "\033[0;31mfakealias\033[0m ")"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die
# expecting in bold yellow and two grays:
nvm set-colors bbbYb
OUTPUT=$(echo $(nvm_print_formatted_alias fakealias fakedest) | awk '{ print substr($0, 1, 21); }')
EXPECTED_OUTPUT="$(command printf %b "\033[1;33mfakealias\033[0m ")"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die

View File

@ -2,7 +2,9 @@
die () { echo "$@" ; exit 1; }
\. ../../../nvm.sh
export NVM_DIR="$(cd ../../.. && pwd)"
\. "${NVM_DIR}/nvm.sh"
EXIT_CODE=$(nvm_resolve_alias ; echo $?)
[ $EXIT_CODE = "1" ] || die "nvm_resolve_alias without an argument did not return 1; got $EXIT_CODE"
@ -31,3 +33,17 @@ UNSTABLE="$(nvm_resolve_alias unstable)"
IOJS="$(nvm_resolve_alias iojs)"
[ "_$IOJS" = "_iojs-v0.2" ] || die "'nvm_resolve_alias iojs' was not iojs-v0.2; got $IOJS"
echo "
v0.0.1
v0.0.2
v0.0.3
" > ../../../alias/test-multi-lines
EXPECTED='v0.0.1'
ACTUAL="$(nvm_resolve_alias test-multi-lines)"
EXIT_CODE="$(nvm_resolve_alias test-multi-lines 2>&1 >/dev/null; echo $?)"
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
[ "${EXIT_CODE}" = '0' ] || die "expected exit code 0, got ${EXIT_CODE}"

View File

@ -1,11 +1,16 @@
#!/bin/sh
export NVM_DIR="$(cd ../../.. && pwd)"
\. ../../../nvm.sh
\. ../../common.sh
for i in $(seq 1 10)
do
echo 0.0.$i > ../../../alias/test-stable-$i
mkdir -p ../../../v0.0.$i
make_fake_node v0.0.$i
echo 0.1.$i > ../../../alias/test-unstable-$i
mkdir -p ../../../v0.1.$i
make_fake_node v0.1.$i
echo 0.2.$i > ../../../alias/test-iojs-$i
mkdir -p ../../../versions/io.js/v0.2.$i
make_fake_iojs v0.2.$i
done

View File

@ -15,3 +15,5 @@ rm -f "../../../alias/unstable"
rm -f "../../../alias/node"
rm -f "../../../alias/iojs"
rm -f "../../../alias/default"
rm -f "../../../alias/test-blank-lines"
rm -f "../../../alias/test-multi-lines"

View File

@ -1,10 +1,11 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
mkdir -p "${NVM_DIR}/v0.0.2"
mkdir -p "${NVM_DIR}/v0.0.20"
mkdir -p "${NVM_DIR}/versions/node/v0.12.0"
make_fake_node v0.0.2
make_fake_node v0.0.20
make_fake_node v0.12.0
die () { echo "$@" ; exit 1; }

View File

@ -1,3 +1,3 @@
rmdir ../../../v0.0.2 >/dev/null 2>&1
rmdir ../../../v0.0.20 >/dev/null 2>&1
rmdir ../../../v0.12.0 >/dev/null 2>&1
rm -rf ../../../v0.0.2
rm -rf ../../../v0.0.20
rm -rf ../../../v0.12.0

View File

@ -1,24 +0,0 @@
#!/bin/sh
\. ../../../nvm.sh
mkdir "${NVM_DIR}/v0.0.1"
mkdir "${NVM_DIR}/v0.0.3"
mkdir "${NVM_DIR}/v0.0.9"
mkdir "${NVM_DIR}/v0.3.1"
mkdir "${NVM_DIR}/v0.3.3"
mkdir "${NVM_DIR}/v0.3.9"
mkdir -p "${NVM_DIR}/versions/node/v0.12.87"
mkdir -p "${NVM_DIR}/versions/node/v0.12.9"
mkdir -p "${NVM_DIR}/versions/io.js/v0.1.2"
mkdir -p "${NVM_DIR}/versions/io.js/v0.10.2"
# The result should contain the version numbers.
nvm ls | grep v0.0.1 >/dev/null &&
nvm ls | grep v0.0.3 >/dev/null &&
nvm ls | grep v0.0.9 >/dev/null &&
nvm ls | grep v0.3.1 >/dev/null &&
nvm ls | grep v0.3.3 >/dev/null &&
nvm ls | grep v0.3.9 >/dev/null &&
nvm ls | grep v0.12.87 >/dev/null &&
nvm ls | grep iojs-v0.1.2 >/dev/null

View File

@ -0,0 +1,34 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }
make_fake_node v0.12.87 || die 'fake v0.12.87 could not be made'
make_fake_node v0.12.9 || die 'fake v0.12.9 could not be made'
make_fake_iojs v0.1.2 || die 'fake iojs-v0.1.2 could not be made'
make_fake_iojs v0.10.2 || die 'fake iojs-v0.10.2 could not be made'
set -e
nvm_list_aliases() {
echo 'sd-6'
}
# sanity check
OUTPUT="$(nvm alias)"
EXPECTED_OUTPUT='sd-6'
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
nvm_ls() {
echo v0.12.87
echo v0.12.9
echo iojs-v0.1.2
echo iojs-v0.10.2
}
OUTPUT="$(nvm ls --no-colors --no-alias)"
EXPECTED_OUTPUT=" v0.12.87 *
v0.12.9 *
iojs-v0.1.2 *
iojs-v0.10.2 *"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "2: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"

View File

@ -0,0 +1,15 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }
set -e
OUTPUT="$(nvm ls --no-colors --no-alias pattern 2>&1 ||:)"
EXPECTED_OUTPUT='`--no-alias` is not supported when a pattern is provided.'
EXIT_CODE="$(nvm ls --no-colors --no-alias pattern >/dev/null 2>&1 || echo $?)"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
[ "${EXIT_CODE}" = 55 ] || die "expected 55; got >${EXIT_CODE}<"

View File

@ -1,9 +1,10 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
mkdir "${NVM_DIR}/v0.0.2"
mkdir "${NVM_DIR}/v0.0.20"
make_fake_node v0.0.2
make_fake_node v0.0.20
die () { echo "$@" ; exit 1; }

View File

@ -1,10 +1,11 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
mkdir "${NVM_DIR}/v0.1.3"
mkdir "${NVM_DIR}/v0.2.3"
mkdir "${NVM_DIR}/v0.20.3"
make_fake_node v0.1.3
make_fake_node v0.2.3
make_fake_node v0.20.3
die () { echo "$@" ; exit 1; }

View File

@ -1,11 +1,12 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
die () { echo "$@" ; exit 1; }
mkdir "${NVM_DIR}/v0.2.3"
mkdir "${NVM_DIR}/v0.3.3"
make_fake_node v0.2.3
make_fake_node v0.3.3
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
@ -19,10 +20,10 @@ nvm ls stable | \grep "$STABLE_VERSION" >/dev/null \
nvm ls unstable | \grep "$UNSTABLE_VERSION" >/dev/null \
|| die "expected 'nvm ls unstable' to give $UNSTABLE_VERSION, got $(nvm ls unstable)"
mkdir "${NVM_DIR}/v0.1.2"
make_fake_node v0.1.4
nvm alias stable 0.1
nvm ls stable | \grep -v "$STABLE_VERSION" >/dev/null \
|| die "'nvm ls stable' contained $STABLE_VERSION instead of v0.1.2"
nvm ls stable | \grep v0.1.2 >/dev/null \
|| die "'nvm ls stable' did not contain v0.1.2"
|| die "'nvm ls stable' contained $STABLE_VERSION instead of v0.1.4"
nvm ls stable | \grep v0.1.4 >/dev/null \
|| die "'nvm ls stable' did not contain v0.1.4"

View File

@ -3,13 +3,14 @@
die () { echo "$@" ; exit 1; }
\. ../../../nvm.sh
\. ../../common.sh
mkdir -p "${NVM_DIR}/v0.0.1"
mkdir -p "${NVM_DIR}/v0.0.3"
mkdir -p "${NVM_DIR}/v0.0.9"
mkdir -p "${NVM_DIR}/v0.3.1"
mkdir -p "${NVM_DIR}/v0.3.3"
mkdir -p "${NVM_DIR}/v0.3.9"
make_fake_node v0.0.1
make_fake_node v0.0.3
make_fake_node v0.0.9
make_fake_node v0.3.1
make_fake_node v0.3.3
make_fake_node v0.3.9
nvm_has_system_node() { return 0; }
nvm ls system | grep system 2>&1 > /dev/null

View File

@ -0,0 +1,35 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
die () { echo "$@" ; unset -f nvm_ls nvm_list_aliases; exit 1; }
make_fake_node v0.12.87 || die 'fake v0.12.87 could not be made'
make_fake_node v0.12.9 || die 'fake v0.12.9 could not be made'
make_fake_iojs v0.1.2 || die 'fake iojs-v0.1.2 could not be made'
make_fake_iojs v0.10.2 || die 'fake iojs-v0.10.2 could not be made'
set -e
nvm_list_aliases() {
echo 'sd-6'
}
# sanity check
OUTPUT="$(nvm alias)"
EXPECTED_OUTPUT='sd-6'
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"
nvm_ls() {
echo v0.12.87
echo v0.12.9
echo iojs-v0.1.2
echo iojs-v0.10.2
}
OUTPUT="$(nvm ls --no-colors)"
EXPECTED_OUTPUT=" v0.12.87 *
v0.12.9 *
iojs-v0.1.2 *
iojs-v0.10.2 *
sd-6"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "2: expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"

View File

@ -0,0 +1,44 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
die () { echo "$@" ; exit 1; }
make_fake_node v0.0.1
make_fake_node v0.0.3
make_fake_node v0.0.9
make_fake_node v0.3.1
make_fake_node v0.3.3
make_fake_node v0.3.9
make_fake_node v0.12.87
make_fake_node v0.12.9
make_fake_iojs v0.1.2
make_fake_iojs v0.10.2
# The result should contain the version numbers.
nvm ls | grep v0.0.1 >/dev/null || die "v0.0.1 not found in: $(nvm ls)"
nvm ls | grep v0.0.3 >/dev/null || die "v0.0.3 not found in: $(nvm ls)"
nvm ls | grep v0.0.9 >/dev/null || die "v0.0.9 not found in: $(nvm ls)"
nvm ls | grep v0.3.1 >/dev/null || die "v0.3.1 not found in: $(nvm ls)"
nvm ls | grep v0.3.3 >/dev/null || die "v0.3.3 not found in: $(nvm ls)"
nvm ls | grep v0.3.9 >/dev/null || die "v0.3.9 not found in: $(nvm ls)"
nvm ls | grep v0.12.87 >/dev/null || die "v0.12.87 not found in: $(nvm ls)"
nvm ls | grep iojs-v0.1.2 >/dev/null || die "iojs-v0.1.2 not found in: $(nvm ls)"
OUTPUT="$(nvm_ls)"
EXPECTED_OUTPUT="v0.0.1
v0.0.3
v0.0.9
iojs-v0.1.2
v0.3.1
v0.3.3
v0.3.9
iojs-v0.10.2
v0.12.9
v0.12.87"
if nvm_has_system_node || nvm_has_system_iojs; then
EXPECTED_OUTPUT="${EXPECTED_OUTPUT}
system"
fi
[ "${OUTPUT-}" = "${EXPECTED_OUTPUT-}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"

View File

@ -1,9 +1,10 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
mkdir "${NVM_DIR}/v0.1.3"
mkdir "${NVM_DIR}/v0.2.3"
make_fake_node v0.1.3
make_fake_node v0.2.3
[ -z `nvm ls | grep '^ *\.'` ]
# The result should contain only the appropriate version numbers.

View File

@ -1,10 +1,10 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
mkdir "${NVM_DIR}/v0.1.3"
mkdir "${NVM_DIR}/v0.2.3"
mkdir -p "${NVM_DIR}/versions/node"
make_fake_node v0.1.3
make_fake_node v0.2.3
[ -z "$(nvm ls | \grep 'versions')" ]
# The result should contain only the appropriate version numbers.

View File

@ -3,13 +3,14 @@
die () { echo "$@" ; exit 1; }
\. ../../../nvm.sh
\. ../../common.sh
mkdir -p "${NVM_DIR}/v0.0.1"
mkdir -p "${NVM_DIR}/v0.0.3"
mkdir -p "${NVM_DIR}/v0.0.9"
mkdir -p "${NVM_DIR}/v0.3.1"
mkdir -p "${NVM_DIR}/v0.3.3"
mkdir -p "${NVM_DIR}/v0.3.9"
make_fake_node v0.0.1
make_fake_node v0.0.3
make_fake_node v0.0.9
make_fake_node v0.3.1
make_fake_node v0.3.3
make_fake_node v0.3.9
nvm_has_system_node() { return 0; }
nvm ls | grep system 2>&1 > /dev/null

View File

@ -3,9 +3,10 @@
die () { echo "$@" ; exit 1; }
\. ../../../nvm.sh
\. ../../common.sh
mkdir -p "${NVM_DIR}/versions/node/v0.12.1"
mkdir "${NVM_DIR}/v0.1.3"
make_fake_node v0.12.1
make_fake_node v0.1.3
nvm ls 0.12 | grep v0.12.1 || die '"nvm ls" did not list a version in the versions/ directory'
nvm ls 0.1 | grep v0.1.3 || die '"nvm ls" did not list a version not in the versions/ directory'

View File

@ -0,0 +1,42 @@
#!/bin/zsh
export NVM_DIR="$(cd ../../.. && pwd)"
\. ../../../nvm.sh
\. ../../common.sh
if type setopt >/dev/null 2>&1; then setopt local_options markdirs; fi
die () {
if type unsetopt >/dev/null 2>&1; then unsetopt local_options markdirs; fi
echo "$@";
exit 1;
}
make_fake_node v0.0.1
make_fake_node v0.0.3
make_fake_node v0.0.9
make_fake_node v0.3.1
make_fake_node v0.3.3
make_fake_node v0.3.9
make_fake_node v0.12.87
make_fake_node v0.12.9
make_fake_iojs v0.1.2
make_fake_iojs v0.10.2
OUTPUT="$(nvm_ls)"
EXPECTED_OUTPUT="v0.0.1
v0.0.3
v0.0.9
iojs-v0.1.2
v0.3.1
v0.3.3
v0.3.9
iojs-v0.10.2
v0.12.9
v0.12.87"
if nvm_has_system_node || nvm_has_system_iojs; then
EXPECTED_OUTPUT="${EXPECTED_OUTPUT}
system"
fi
[ "${OUTPUT-}" = "${EXPECTED_OUTPUT-}" ] || die "expected >${EXPECTED_OUTPUT}<; got >${OUTPUT}<"

View File

@ -1,8 +1,9 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
mkdir "${NVM_DIR}/v0.1.2"
make_fake_node v0.1.2
nvm ls v0.1 | grep v0.1.2 &&
nvm ls v0.1.2 | grep v0.1.2 &&

View File

@ -0,0 +1,23 @@
#!/bin/sh
die () { echo "$@" ; exit 1; }
\. ../../../nvm.sh
\. ../../common.sh
make_fake_node v0.12.34 || die 'fake v0.12.34 could not be made'
# Enable no unset variable
set -u
# Try an alias that does not exist
output=$(nvm ls 99 2>&1 1>/dev/null || true)
test -z "${output}" || die "1: expected empty; got >${output}"
# Try a version that does not exist
output=$(nvm ls 0.12.00 2>&1 1>/dev/null || true)
test -z "${output}" || die "2: expected empty; got >${output}"
# Try a version that does exist
output=$(nvm ls 0.12.34 2>&1 1>/dev/null || true)
test -z "${output}" || die "3: expected empty; got >${output}"

View File

@ -0,0 +1,19 @@
#!/bin/sh
\. ../../../nvm.sh
\. ../../common.sh
make_fake_node v0.0.1
make_fake_node v0.0.3
make_fake_node v0.0.9
make_fake_node v0.3.1
make_fake_node v0.3.3
make_fake_node v0.3.9
make_fake_node v0.12.87
make_fake_node v0.12.9
make_fake_iojs v0.1.2
make_fake_iojs v0.10.2
set -e
IFS='' nvm ls

View File

@ -1,17 +1,16 @@
rmdir ../../../v0.0.1 >/dev/null 2>&1
rmdir ../../../v0.0.2 >/dev/null 2>&1
rmdir ../../../v0.0.3 >/dev/null 2>&1
rmdir ../../../v0.0.9 >/dev/null 2>&1
rmdir ../../../v0.0.20 >/dev/null 2>&1
rmdir ../../../v0.1.2 >/dev/null 2>&1
rmdir ../../../v0.1.3 >/dev/null 2>&1
rmdir ../../../v0.2.3 >/dev/null 2>&1
rmdir ../../../v0.3.1 >/dev/null 2>&1
rmdir ../../../v0.3.3 >/dev/null 2>&1
rmdir ../../../v0.3.9 >/dev/null 2>&1
rmdir ../../../v0.20.3 >/dev/null 2>&1
rmdir ../../../versions >/dev/null 2>&1
unalias nvm_has_system_node >/dev/null 2>&1
rm -f ../../../alias/stable >/dev/null 2>&1
rm -f ../../../alias/unstable >/dev/null 2>&1
rm -rf ../../../v0.0.1
rm -rf ../../../v0.0.2
rm -rf ../../../v0.0.3
rm -rf ../../../v0.0.9
rm -rf ../../../v0.0.20
rm -rf ../../../v0.1.2
rm -rf ../../../v0.1.3
rm -rf ../../../v0.1.4
rm -rf ../../../v0.2.3
rm -rf ../../../v0.3.1
rm -rf ../../../v0.3.3
rm -rf ../../../v0.3.9
rm -rf ../../../v0.20.3
rm -rf ../../../versions
rm -f ../../../alias/stable
rm -f ../../../alias/unstable

View File

@ -1,22 +0,0 @@
#!/bin/sh
set -ex
mkdir -p ../../v0.2.3
die () { echo "$@" ; exit 1; }
[ `expr $PATH : ".*v0.2.3/.*/bin"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
\. ../../nvm.sh
nvm use --delete-prefix v0.2.3 || die "Failed to activate v0.2.3"
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` != 0 ] || die "PATH not set up properly"
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
[ `expr "$NVM_BIN" : ".*v0.2.3/bin"` != 0 ] || die "NODE_BIN should contain bin directory path"
nvm deactivate || die "Failed to deactivate v0.2.3"
[ `expr "$PATH" : ".*v0.2.3/.*/bin"` = 0 ] || die "PATH not cleaned properly"
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules"` = 0 ] || die "NODE_PATH not cleaned properly"
[ "_$NVM_BIN" = "_" ] || die "NVM_BIN should be unset: got '$NVM_BIN'"

View File

@ -1,12 +0,0 @@
#!/bin/sh
set -ex
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/files' ]

View File

@ -2,6 +2,8 @@
set -ex
export NVM_DIR="$(cd ../.. && pwd)"
\. ../../nvm.sh
nvm alias test v0.1.2

View File

@ -4,6 +4,8 @@ set -ex
die () { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../.. && pwd)"
\. ../../nvm.sh
nvm deactivate 2>&1

View File

@ -0,0 +1,25 @@
#!/bin/sh
set -ex
die () { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../.. && pwd)"
\. ../../nvm.sh
\. ../common.sh
make_fake_node v0.2.3
[ `expr $PATH : ".*v0.2.3/.*/bin.*"` = 0 ] || echo "WARNING: Unexpectedly found v0.2.3 already active" >&2
nvm use --delete-prefix v0.2.3 || die "Failed to activate v0.2.3"
[ `expr "$PATH" : ".*v0.2.3/.*/bin.*"` != 0 ] || die "PATH not set up properly"
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules.*"` = 0 ] || die "NODE_PATH should not contain (npm root -g)"
# ^ note: NODE_PATH should not contain `npm root -g` since globals should not be requireable
[ `expr "$NVM_BIN" : ".*v0.2.3/bin"` != 0 ] || die "NODE_BIN should contain bin directory path"
nvm deactivate || die "Failed to deactivate v0.2.3"
[ `expr "$PATH" : ".*v0.2.3/.*/bin.*"` = 0 ] || die "PATH not cleaned properly"
[ `expr "$NODE_PATH" : ".*v0.2.3/.*/lib/node_modules.*"` = 0 ] || die "NODE_PATH not cleaned properly"
[ "_$NVM_BIN" = "_" ] || die "NVM_BIN should be unset: got '$NVM_BIN'"

View File

@ -7,9 +7,12 @@ cleanup () {
rm -rf "${NVM_DIR}/v0.10.4"
}
\. ../../nvm.sh
export NVM_DIR="$(cd ../.. && pwd)"
mkdir "${NVM_DIR}/v0.10.4"
\. ../../nvm.sh
\. ../common.sh
make_fake_node v0.10.4
nvm deactivate >/dev/null 2>&1
@ -39,4 +42,18 @@ set -e
[ $INSTALL_EXIT_CODE -eq 4 ] \
|| die ""nvm install --reinstall-packages-from" should exit with code 4 when given the same version, got $INSTALL_EXIT_CODE"
set +ex # needed for stderr
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from 2>&1)"
set -ex
EXPECTED_ERROR_MSG='If --reinstall-packages-from is provided, it must point to an installed version of node using `=`.'
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
set +ex # needed for stderr
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from= 2>&1)"
set -ex
EXPECTED_ERROR_MSG="If --reinstall-packages-from is provided, it must point to an installed version of node."
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
cleanup

View File

@ -4,6 +4,8 @@ set -ex
die () { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../.. && pwd)"
\. ../../nvm.sh
set +ex # needed for stderr

View File

@ -0,0 +1,12 @@
#!/bin/sh
set -ex
\. ../../nvm.sh
\. ../common.sh
make_fake_node v0.0.1
nvm uninstall v0.0.1
[ ! -d 'v0.0.1' ]

View File

@ -2,13 +2,11 @@
set -ex
cd ../..
mkdir v0.0.1
mkdir src/node-v0.0.1
\. ../../nvm.sh
\. ../common.sh
sudo touch v0.0.1/sudo
. ./nvm.sh
make_fake_node v0.0.1
sudo touch ""$(nvm_version_path v0.0.1)"/sudo"
RETURN_MESSAGE="$(nvm uninstall v0.0.1 2>&1 || echo)"
CHECK_FOR="Cannot uninstall, incorrect permissions on installation folder"

View File

@ -9,18 +9,22 @@ cleanup () { rm -f "${BEFORE}" "${AFTER}"; }
die () { echo "$@" ; cleanup ; exit 1; }
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${BEFORE}"
env | grep -v PATH= | grep -v IFS= | grep -v NVM_ | grep -v TRAVIS_ | sort >> "${BEFORE}"
set +e # TODO: fix
\. ../../nvm.sh
set -e
type nvm > /dev/null 2>&1 || die "nvm not loaded"
nvm unload
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${AFTER}"
env | grep -v PATH= | grep -v IFS= | grep -v TRAVIS_ | sort >> "${AFTER}"
! type nvm > /dev/null 2>&1 || die "nvm not unloaded"
DIFF="$(diff "${BEFORE}" "${AFTER}" ||:)"
[ -z "${DIFF}" ] || die "function pollution found: ${DIFF}"
[ -z "${DIFF}" ] || die "function pollution found: >${DIFF}<"
cleanup

Some files were not shown because too many files have changed in this diff Show More