forked from mozilla/fireplace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
49 lines (38 loc) · 1.15 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
49
import os
import re
# JS
blacklist = [
'jquery.cookie.js',
'require.js',
'settings_inferno.js',
'settings_local.js',
'settings_travis.js',
'stick.js',
'suggestions.js',
]
output = []
for root, _, files in os.walk('hearth/media/js'):
for f in files:
if not f.endswith('.js'):
continue
if f in blacklist:
continue
with open(os.path.join(root, f)) as file_:
output.append(file_.read())
with open('hearth/templates.js') as file_:
output.append(file_.read())
with open('hearth/media/include.js') as inc:
inc_data = inc.read()
with open('hearth/media/include.js', mode='w') as inc:
inc.write(inc_data.replace("'replace me'", '\n'.join(output)))
# CSS
css_pattern = re.compile(r'href="(\/media\/css\/.+\.styl\.css)"', re.I)
with open('hearth/index.html') as file_:
index_html = file_.read()
css_files = css_pattern.findall(index_html)
output = []
for css_file in css_pattern.findall(index_html):
with open('hearth%s' % css_file) as file_:
output.append(file_.read())
with open('hearth/media/include.css', mode='wa') as inc:
inc.write('\n'.join(output))