Skip to content

Commit

Permalink
Improve examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Nov 3, 2019
1 parent 1e4e3cf commit 54bc623
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
38 changes: 19 additions & 19 deletions examples/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,53 @@
# Ignore the following line: this is only needed for internal purposes.
. "$(dirname "$BASH_SOURCE")/utils.sh"

# Same as `node --version` but with Node 12
print "Same as 'node --version' but with Node 12"
nve 12 node --version

# Same as `node file.js` but with Node 8
print "Same as 'node file.js' but with Node 8"
nve 8 node file.js

# Any command can be used, including local binaries
print "Any command can be used, including local binaries"
nve 8 npm --version

# Run multiple versions
print "Run multiple versions"
nve 12 10 8 node --version

# Do not abort on the first version that fails
print "Do not abort on the first version that fails"
nve --continue 12 10 8 node --version

# Run all versions in parallel
print "Run all versions in parallel"
nve --parallel 12 10 8 node --version

# Run a specific version
print "Run a specific version"
nve 8.10.0 node --version

# Run the latest Node version
nve '*' node --version
print "Run the latest Node version"
nve "*" node --version

# Use a version range
nve '<8' node --version
print "Use a version range"
nve "<8" node --version

# Use a different mirror for the Node binaries
print "Use a different mirror for the Node binaries"
nve --mirror=https://npm.taobao.org/mirrors/node 8 node --version

# Chaining commands without a shell
print "Chaining commands without a shell"
nve 8 node --version && nve 8 node file.js

# Chaining commands with a shell
print "Chaining commands with a shell"
nve --shell 8 "node --version && node file.js"

# Cache Node 8 download
print "Cache Node 8 download"
nve 8 node --version

# Cache multiple Node downloads
print "Cache multiple Node downloads"
nve 12 10 8 node --version

# Prints latest Node.js version. Make sure you use quotes.
print "Prints latest Node.js version. Make sure you use quotes."
nve "*"

# Prints latest Node.js 8 version
print "Prints latest Node.js 8 version"
nve 8

# Prints latest Node.js 12, 10 and 8 versions
print "Prints latest Node.js 12, 10 and 8 versions"
nve 12 10 8
4 changes: 4 additions & 0 deletions examples/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ shopt -s expand_aliases
# We create an alias so that examples look the same as if the library was
# directly installed.
alias "$binaryName"="$projectRoot/$pathToBinary"

print() {
echo -e "\n\e[36m# $1\e[0m"
}

0 comments on commit 54bc623

Please sign in to comment.