-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.py
48 lines (34 loc) · 1.37 KB
/
build.py
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
48
import os
import os.path
import subprocess
import shutil
shutil.rmtree('dist')
if not os.path.exists('dist'):
os.mkdir('dist')
label = raw_input('Build label > ')
main_fname = 'compiled.%s.js' % (label, )
main_path = os.path.join('dist', main_fname)
subprocess.check_call(['browserify', 'src/main.js', '-o', main_path])
worker_fname = 'worker.%s.js' % (label, )
worker_path = os.path.join('dist', worker_fname)
subprocess.check_call(['browserify', 'src/worker.js', '-o', worker_path])
with open(main_path, 'r') as f:
data = f.read()
data = data.replace('worker_compiled.js', worker_fname)
with open(main_path, 'w') as f:
f.write(data)
index_fname = os.path.join('dist', 'index.html')
with open('index.html', 'r') as infile, open(index_fname, 'w') as ofile:
data = infile.read()
data = data.replace('compiled.js', main_fname)
data = data.replace('<title>grinder</title>', '<title>grinder (build %s)</title>' % (label, ))
ofile.write(data)
files = []
scp_command = ['scp']
scp_command.extend([os.path.join('dist', fname) for fname in os.listdir('dist')])
scp_command.append('asdf@trewq:/var/www/html/wurm/keenanisafag/')
subprocess.check_call(scp_command)
# scp_command = ['scp']
# scp_command.extend([os.path.join('dist', fname) for fname in os.listdir('dist')])
# scp_command.append('asdf@trewq:/var/www/html/wurm/grinder/')
# subprocess.check_call(scp_command)