Skip to content

Commit a9556bb

Browse files
committed
why do we compile in release mode anyway?
1 parent ff3260e commit a9556bb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

minify.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55
from __future__ import print_function
66

7+
import re
78
import sys
89

910
import bs4
@@ -26,7 +27,18 @@ def main(argv):
2627
html = bs4.BeautifulSoup(response.text, 'html.parser')
2728
textarea = [ta for ta in html.find_all('textarea')
2829
if ta.get('name') != 'user_source'][0]
29-
print(textarea.text)
30+
minified = textarea.text
31+
32+
# fix minifier bugs:
33+
# * semicolon before function declaration requires additional whitespace
34+
# * ampersand (for background jobs) gets an erroneous semicolon
35+
# at the end of a function
36+
minified = re .sub(
37+
r';(\w+)\(\)', lambda m: '; %s()' % m.group(1), minified)
38+
minified = minified.replace('&;}', '&}')
39+
40+
print("#!/bin/bash")
41+
print(minified)
3042

3143

3244
if __name__ == '__main__':

0 commit comments

Comments
 (0)