Commit Graph

912 Commits

Author SHA1 Message Date
Mário Feroldi
8d97975bc3
Make nvm visible to shell children
Shell functions are not automatically exported when declared, which
turned out to be problematic when sourcing the `nvm.sh` file from a
login shell. Non-login shells, which are children of the login shell,
do not see the `nvm` function when it's sourced from `~/.profile` and
other similar profile files.

Take the following code as an example (using bash):

    $ foo() { echo 1; } # in login shell
    $ foo
    1
    $ bash # in non-login shell now
    $ foo
    bash: foo: command not found

`foo` is not seen by the second bash instance, even though it has been
declared by its parent process.

One of the solutions is to export `foo` right after declaring it by
doing `export -f NAME`:

    $ foo() { echo 1; } # in login shell
    $ export -f foo
    $ bash # in non-login shell now
    $ foo
    1

This commit does the same to the `nvm` function and its dependencies.
2019-11-19 15:43:46 -03: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
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
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
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
Jordan Harband
e7a5b7992b
[meta] update repo links to point to org 2019-04-24 16:08:34 -07:00
Christopher Sahnwaldt
2410215b6a
[Refactor] add nvm_stdout_is_terminal helper 2019-02-24 00:03:19 +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
Jordan Harband
e0d87528f3
[shellcheck] remove unnecessary overrides 2019-02-24 23:04:13 -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
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
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
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
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
7f9220dbd8
[Fix] nvm ls: --no-colors: system: print an asterisk 2019-02-23 14:41:57 -08: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
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
Jordan Harband
3d9c31d944
v0.34.0 2019-01-07 23:01:16 -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
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
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
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
Xandor Schiefer
eabd7ab13d
Respect previously nvm-loaded node version when sourcing 2016-11-14 19:18:24 +02: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
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
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
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
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
09f7bbb78c
[Refactor] use a different approach to remove trailing slashes 2018-04-24 13:24:08 -07:00