]> git.wincent.com - wincent.git/commitdiff
refactor: make bin/ helper scripts
authorGreg Hurrell <greg@hurrell.net>
Thu, 19 Mar 2020 20:09:22 +0000 (21:09 +0100)
committerGreg Hurrell <greg@hurrell.net>
Fri, 20 Mar 2020 09:53:24 +0000 (10:53 +0100)
bin/n [new file with mode: 0755]
bin/node [new file with mode: 0755]
bin/yarn [new file with mode: 0755]
install-next

diff --git a/bin/n b/bin/n
new file mode 100755 (executable)
index 0000000..2ad3b40
--- /dev/null
+++ b/bin/n
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+set -e
+
+REPO_ROOT="${BASH_SOURCE%/*}/.."
+VENDOR_ROOT="$REPO_ROOT/vendor"
+N_EXE="$VENDOR_ROOT/n/bin/n"
+N_PREFIX="$VENDOR_ROOT/node"
+
+export N_PREFIX
+
+if [[ ! -x $N_EXE ]]; then
+  echo "[abort] No executable at $N_EXE; did you forget to \`git submodule init\`?" /dev/stderr
+  exit 1
+fi
+
+if ! "$N_EXE" which lts &> /dev/null; then
+  echo "[status] Installing Node LTS version" > /dev/stderr
+  "$N_EXE" lts
+else
+  echo "[status] Using Node LTS installation" > /dev/stderr
+fi
+
+"$N_EXE" "$@"
diff --git a/bin/node b/bin/node
new file mode 100755 (executable)
index 0000000..44010ab
--- /dev/null
+++ b/bin/node
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+set -e
+
+REPO_ROOT="${BASH_SOURCE%/*}/.."
+N_EXE="$REPO_ROOT/bin/n"
+
+"$N_EXE" run lts "$@"
diff --git a/bin/yarn b/bin/yarn
new file mode 100755 (executable)
index 0000000..1c35f2f
--- /dev/null
+++ b/bin/yarn
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -e
+
+REPO_ROOT="${BASH_SOURCE%/*}/.."
+N_EXE="$REPO_ROOT/bin/n"
+YARN_EXE="$REPO_ROOT/vendor/yarn-v1.22.4/bin/yarn"
+
+"$N_EXE" exec lts "$YARN_EXE" "$@"
index e255abb9ab6d9dc8662707b78217f6227ee13c69..6b676e2d7fc77b343504d97484c822b6a272d88e 100755 (executable)
@@ -3,38 +3,19 @@
 set -e
 
 REPO_ROOT="${BASH_SOURCE%/*}"
+BIN_DIR="$REPO_ROOT/bin"
+NODE_EXE="$BIN_DIR/node"
+YARN_EXE="$BIN_DIR/yarn"
 MAIN_EXE="$REPO_ROOT/lib/main.js"
-VENDOR_ROOT="$REPO_ROOT/vendor"
-N_EXE="$VENDOR_ROOT/n/bin/n"
-N_PREFIX="$VENDOR_ROOT/node"
-YARN_EXE="$VENDOR_ROOT/yarn-v1.22.4/bin/yarn"
-
-export N_PREFIX
-
-for ARG in "$@"; do
-  if [ "$ARG" = "--force" -o "$ARG" = "-f" ]; then
-    FORCE=1
-  fi
-done
-
-if [[ ! -x $N_EXE ]]; then
-  echo "[abort] No executable at $N_EXE; did you forget to \`git submodule init\`?"
-  exit 1
-fi
-
-if ! "$N_EXE" which lts &> /dev/null; then
-  echo "[status] Installing Node LTS version"
-  "$N_EXE" lts
-fi
 
 echo "[status] Installing TypeScript"
 
-"$N_EXE" exec lts "$YARN_EXE" --frozen-lockfile --no-default-rc --no-progress --silent
+"$YARN_EXE" --frozen-lockfile --no-default-rc --no-progress --silent
 
 echo "[status] Building"
 
-"$N_EXE" exec lts "$YARN_EXE" run --silent tsc
+"$YARN_EXE" run --silent tsc
 
 echo "[status] Running main"
 
-"$N_EXE" run lts "$MAIN_EXE" "$@"
+"$NODE_EXE" "$MAIN_EXE" "$@"