]> git.wincent.com - wincent.git/blob - install-next
feat: create seed version of "install-next" script
[wincent.git] / install-next
1 #!/bin/bash
2
3 set -e
4
5 REPO_ROOT="${BASH_SOURCE%/*}"
6 DENO_BASE="$REPO_ROOT/vendor/deno"
7 DENO_INSTALLER="$DENO_BASE/install.sh"
8 DENO_INSTALL="$DENO_BASE/local"
9 DENO_EXE="$DENO_INSTALL/bin/deno"
10 DENO_TYPES="$DENO_BASE/types.d.ts"
11
12 for ARG in "$@"; do
13   if [ "$ARG" = "--force" -o "$ARG" = "-f" ]; then
14     FORCE=1
15   fi
16 done
17
18 if [[ ! -e "$DENO_INSTALLER" || $FORCE ]]; then
19   echo "[status] Fetching Deno installer"
20   command curl -fsSL -o "$DENO_INSTALLER" https://deno.land/x/install/install.sh
21 else
22   echo "[skip] Fetch Deno installer; use -f to force re-fetch"
23 fi
24
25 if [[ ! -e "$DENO_EXE" || $FORCE ]]; then
26   echo "[status] Run Deno installer"
27   export DENO_INSTALL
28   command sh "$DENO_INSTALLER"
29 else
30   echo "[skip] Run Deno installer; use -f to force re-install"
31 fi
32
33 if [[ ! -e "$DENO_TYPES" || $FORCE ]]; then
34   echo "[status] Generate Deno types"
35   "$DENO_EXE" types > "$DENO_TYPES"
36 else
37   echo "[skip] Generate Deno types; use -f to force re-generation"
38 fi
39
40 echo "[status] Running main"
41 "$DENO_EXE" run --allow-all lib/main.ts "$@"