-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwerk
executable file
·45 lines (40 loc) · 891 Bytes
/
werk
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
#!/usr/bin/env bash
ESCAPE=$'\e'
red_text="${ESCAPE}[1;31;47m"
normal_text="${ESCAPE}[0m"
echo_error() {
msg=$1
echo "$red_text!!! $msg !!!$normal_text"
}
# make sure we have zx
if [ -z `which zx` ]; then
if [ -z `which node` ]; then
echo "Stopping because it looks like we don't have NodeJS installed."
case `uname` in
"Darwin")
echo_error "If you're using Homebrew, you could \`brew install node\`"
;;
"Linux")
echo_error <<EOF
You could do:
$ sudo apt update
$ sudo apt install nodejs
EOF
;;
*)
echo_error "Please install NodeJS and run this again."
esac
exit 1
else
npm i -g zx
fi
fi
# let's work from here
werkstatt_dir="$(realpath $(dirname $0))"
if [ "$(pwd)" != "$werkstatt_dir" ]; then
pushd $werkstatt_dir > /dev/null
fi
if [ ! -f ./package-lock.json ]; then
npm install
fi
npm run --silent zx -- $@