From 54bc623e0cd12c0bd239553f2162dd7236b09eed Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 3 Nov 2019 15:14:21 +0100 Subject: [PATCH] Improve examples --- examples/main.sh | 38 +++++++++++++++++++------------------- examples/utils.sh | 4 ++++ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/examples/main.sh b/examples/main.sh index b42cec5..e95c14d 100755 --- a/examples/main.sh +++ b/examples/main.sh @@ -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 diff --git a/examples/utils.sh b/examples/utils.sh index 39174bd..183af0b 100644 --- a/examples/utils.sh +++ b/examples/utils.sh @@ -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" +}