Skip to content

Commit 93771a7

Browse files
jumbosushiljharb
andcommitted
[Tests] nvm exec/nvm run: add --silent tests
Co-authored-by: Atsushi Yamamoto <[email protected]> Co-authored-by: Jordan Harband <[email protected]>
1 parent bc65f54 commit 93771a7

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
die () { echo "$@" ; exit 1; }
6+
7+
. ../../../nvm.sh
8+
9+
echo "0.10.7" > .nvmrc
10+
11+
# Check nvm run without --silent
12+
OUTPUT="$(nvm run --version)"
13+
EXPECTED_OUTPUT="
14+
Found '${PWD}/.nvmrc' with version <0.10.7>
15+
Running node v0.10.7 (npm v1.2.21)
16+
v0.10.7
17+
"
18+
[ ">${OUTPUT}<" = ">${EXPECTED_OUTPUT}<" ] \
19+
|| die "\`nvm run\` failed to run; did not match with the .nvmrc version; got >${OUTPUT}<"
20+
21+
OUTPUT="$(nvm run --silent --version)"
22+
EXPECTED_OUTPUT="v0.10.7"
23+
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] \
24+
|| die "\`nvm run --silent\` failed to run silently; expected no output, got >${OUTPUT}<"
25+
26+
# Output shouldn't be silent if --silent flag is not at the third argument position
27+
OUTPUT="$(nvm run --version --silent)"
28+
EXPECTED_OUTPUT=""
29+
[ "${OUTPUT}" != "${EXPECTED_OUTPUT}" ] \
30+
|| die "\`nvm run --version --silent\` should not be silent; expected >${OUTPUT}<, got no output"

0 commit comments

Comments
 (0)