-
Notifications
You must be signed in to change notification settings - Fork 1
/
npm.script.template
43 lines (33 loc) · 1.1 KB
/
npm.script.template
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
#!/usr/bin/env bash
### Move this file to same level as your package.json
### Update the PROXY_COMMAND_DIR to reflect your ProxyLocal installation path
### Update your package.json to include in scripts: "proxy": "./proxy-up && <rest-of-your-commands>"
ORIGINAL_DIR=$(pwd)
PROXY_COMMAND_DIR="../../ProxyLocal/commands"
# See if we are in the right place
# If path exists
if [ -d "$PROXY_COMMAND_DIR" ]; then
# If path is a directory
if [ -d "$PROXY_COMMAND_DIR" ]; then
# If path is a directory
cd "$PROXY_COMMAND_DIR"
fi
else
# If path is not a directory
printf "ProxyLocal/commands was not found at ../../ProxyLocal/commands\n"
fi
# Detect if ProxyLocal is running
if [ -z "$(docker ps -q -f name=proxylocal-proxy-1)" ]; then
printf "ProxyLocal is not running\n"
./proxy-up
else
printf "ProxyLocal is running\n"
fi
# Run Proxy Nginx to "enable" this site in ProxyLocal's nginx/sites-enabled
if [ -f "proxy-nginx" ]; then
./proxy-nginx -p=PORT
printf "If successful, site running at: \n\n"
echo "👉 SITE" | sed -e "s/.*/"$'\e[32m'"&"$'\e[m'"/"
printf "\n"
fi
cd $ORIGINAL_DIR