]> git.wincent.com - wincent.git/commitdiff
feat: avoid querying for latest Node version
authorGreg Hurrell <greg@hurrell.net>
Mon, 15 Jun 2020 17:09:08 +0000 (19:09 +0200)
committerGreg Hurrell <greg@hurrell.net>
Mon, 15 Jun 2020 17:09:08 +0000 (19:09 +0200)
Avoids:

    Error: failed to download version index (https://nodejs.org/dist/index.tab)

if you try to run without a network connection.

Obviously, `install` will only work if the 14.4.0 has been previously
downloaded, and the Yarn cache has been primed, but if you were able to
clone the repo and run it once, the above will probably be true.

bin/common
bin/n
bin/node
bin/yarn

index 1dbaf9e588ceb9075c30d003b7cec501d5784b84..de87a528fe3fc0f7208156ad18043f970cdef78c 100755 (executable)
@@ -18,6 +18,8 @@ REPO_ROOT=$(cd "${BASH_SOURCE%/*}/.." && pwd)
 
 BIN_DIR="$REPO_ROOT/bin"
 
 
 BIN_DIR="$REPO_ROOT/bin"
 
+NODE_VERSION=14.4.0
+
 export PATH="$BIN_DIR":$PATH
 
 # https://stackoverflow.com/a/5947802/2103996
 export PATH="$BIN_DIR":$PATH
 
 # https://stackoverflow.com/a/5947802/2103996
diff --git a/bin/n b/bin/n
index 6725c6f426808fdd5173027671c0152b1bc93f17..9f574fe30d6fa85898baf09b5e2e5b04d9e20357 100755 (executable)
--- a/bin/n
+++ b/bin/n
@@ -17,11 +17,11 @@ if [[ ! -x $N_EXE ]]; then
   exit 1
 fi
 
   exit 1
 fi
 
-if ! "$N_EXE" which latest &> /dev/null; then
-  log_info "Installing Node latest version"
-  "$N_EXE" latest
+if ! "$N_EXE" which "$NODE_VERSION" &> /dev/null; then
+  log_info "Installing Node $NODE_VERSION"
+  "$N_EXE" $NODE_VERSION
 else
 else
-  log_debug "Using Node latest installation"
+  log_debug "Using Node $NODE_VERSION installation"
 fi
 
 "$N_EXE" "$@"
 fi
 
 "$N_EXE" "$@"
index 614013e3066555042526c28d89aa51d2f1e11d94..beeec4cfbb919f46514f0f90a84db5f85a60ac5b 100755 (executable)
--- a/bin/node
+++ b/bin/node
@@ -6,4 +6,4 @@ REPO_ROOT="${BASH_SOURCE%/*}/.."
 
 source "$REPO_ROOT/bin/common"
 
 
 source "$REPO_ROOT/bin/common"
 
-n run latest "$@"
+n run "$NODE_VERSION" "$@"
index c067f90fcd320cd4347d8e56f28840734ea0ccbf..74ac18e5201a3f941ff704a69824a16e0946a596 100755 (executable)
--- a/bin/yarn
+++ b/bin/yarn
@@ -8,4 +8,4 @@ source "$REPO_ROOT/bin/common"
 
 YARN_EXE="$REPO_ROOT/vendor/yarn-v1.22.4/bin/yarn"
 
 
 YARN_EXE="$REPO_ROOT/vendor/yarn-v1.22.4/bin/yarn"
 
-n exec latest "$YARN_EXE" "$@"
+n exec "$NODE_VERSION" "$YARN_EXE" "$@"