forked from crosscloudci/ci-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_env_js
executable file
·47 lines (39 loc) · 974 Bytes
/
create_env_js
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
#!/bin/bash
function usage() {
echo "$(basename $0) [-noclobber]"
}
if [ -z "$API_URL" ] ; then
echo "Set API_URL environment variable, then run:"
usage
exit 1
fi
OVERWRITE_CONF=1
if [ "$1" = "-nc" -o "$1" = "-noclobber" ] ; then
OVERWRITE_CONF=0
fi
dev_config_file="config/dev.env.js"
prod_config_file="config/prod.env.js"
if [ ! -f "$dev_config_file" -o "$OVERWRITE_CONF" = 1 ] ; then
echo "Creating $dev_config_file"
cat <<-EOF> $dev_config_file
var merge = require('webpack-merge')
var prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
API_URL: '"$API_URL"'
})
EOF
else
echo "$dev_config_file exists - not overwiting"
fi
if [ ! -f "$prod_config_file" -o "$OVERWRITE_CONF" = 1 ] ; then
echo "Creating $prod_config_file"
cat <<-EOF> $prod_config_file
module.exports = {
NODE_ENV: '"production"',
API_URL: '"$API_URL"'
}
EOF
else
echo "$prod_config_file exists - not overwiting"
fi