-
Notifications
You must be signed in to change notification settings - Fork 12
/
cliw
executable file
·32 lines (28 loc) · 851 Bytes
/
cliw
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
#!/bin/sh
# Copyright 2023 Jacob Hummer
# SPDX-License-Identifier: Apache-2.0
# Based on https://github.com/jcbhmr/deno_wrapper
set -e
# https://stackoverflow.com/a/29835459
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
deno_dir="$script_dir/.deno"
# https://manpages.ubuntu.com/manpages/kinetic/en/man1/chronic.1.html
chronic() (
set +e
output=$($@ 2>&1)
exit_code=$?
set -e
if [ "$exit_code" -ne 0 ]; then
echo "$output" >&2
fi
return "$exit_code"
)
if [ ! -d "$deno_dir" ]; then
# https://github.com/denoland/deno_install#readme
export DENO_INSTALL=$deno_dir
curl -fsSL https://deno.land/x/install/install.sh | chronic sh -s "v1.35.1"
fi
# https://github.com/denoland/deno_install/blob/master/install.sh#L53
export DENO_INSTALL=$deno_dir
export PATH="$DENO_INSTALL/bin:$PATH"
exec "$script_dir/cli.ts" "$@"