-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy.py
More file actions
38 lines (34 loc) · 1.05 KB
/
deploy.py
File metadata and controls
38 lines (34 loc) · 1.05 KB
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
# Examples of usage
# python deploy.py -e development
# python deploy.py --environment dev
from shutil import copyfile
import sys, getopt
def main(argv):
environment = ''
try:
opts, args = getopt.getopt(argv, "he:", ["environment="])
except getopt.GetoptError:
print 'deploy.py -e <environment>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'deploy.py -e <environment>'
sys.exit()
elif opt in ("-e", "--environment"):
environment = arg
if environment == 'production':
copyfile('./server.prod.js', './server.js');
print 'Done.'
if environment == 'prod':
copyfile('./server.prod.js', './server.js');
print 'Done.'
elif environment == 'development':
copyfile('./server.dev.js', './server.js');
print 'Done.'
elif environment == 'dev':
copyfile('./server.dev.js', './server.js');
print 'Done.'
else:
print 'Unknow environment.'
if __name__ == "__main__":
main(sys.argv[1:])