forked from timbertson/foperator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chored
executable file
·59 lines (48 loc) · 1.36 KB
/
chored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# NOTE: This file is generated by chored
_main() {
set -euo pipefail
if [ -z "${DENO:-}" ]; then
DENO="$(which deno 2>/dev/null || true)"
fi
if [ -z "${DENO:-}" ]; then
CHORED_CACHE="${CHORED_CACHE:-$HOME/.cache/chored}"
DENO_VERSION="${DENO_VERSION:-1.18.0}"
PLATFORM_ARCH=""
# Add more as needed
case "$(uname -sm)" in
"Darwin x86_64")
PLATFORM_ARCH="x86_64-apple-darwin"
;;
"Linux x86_64")
PLATFORM_ARCH="x86_64-unknown-linux-gnu"
;;
esac
[ -n "$PLATFORM_ARCH" ]
DENO_DIR="$CHORED_CACHE/$PLATFORM_ARCH-$DENO_VERSION/"
mkdir -p "$DENO_DIR"
DENO="$DENO_DIR/deno"
if [ ! -e "$DENO" ]; then
ZIP_FILE="$DENO_DIR/deno.zip"
curl -sSL "https://github.com/denoland/deno/releases/download/v$DENO_VERSION/deno-$PLATFORM_ARCH.zip" > "$ZIP_FILE"
unzip -d "$DENO_DIR" "$ZIP_FILE"
rm "$ZIP_FILE"
fi
fi
DENO_ARGV=(--unstable --allow-all)
here="$PWD"
LOCKFILE="choredefs/.lock.json"
if [ -e "$LOCKFILE" ]; then
DENO_ARGV+=(--lock="$LOCKFILE")
fi
if [ -n "${DENO_ARGS:-}" ]; then
DENO_ARGV+=($DENO_ARGS)
fi
if [ "${1:-}" = "--deno" ]; then
shift
exec "$DENO" "$@"
fi
CHORED_MAIN_FALLBACK='https://raw.githubusercontent.com/timbertson/chored/c89447a118d8e2150de789a603716a87bd3d5559/lib/main.ts'
exec "$DENO" run "${DENO_ARGV[@]}" "${CHORED_MAIN:-$CHORED_MAIN_FALLBACK}" "$@"
}
_main "$@"