summaryrefslogtreecommitdiffstats
path: root/minify_web_js.py
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2016-11-27 21:36:10 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2016-11-28 12:59:03 +0000
commita48c01c3a55b84a43f768e4dd82836209539729b (patch)
tree8345edd036ee0e86f3e91c7c7d3623fe82b2e97c /minify_web_js.py
parent7468078b719fb51f12f6c5f9741b18a4421eb5b0 (diff)
downloaddeluge-a48c01c3a55b84a43f768e4dd82836209539729b.tar.gz
deluge-a48c01c3a55b84a43f768e4dd82836209539729b.tar.bz2
deluge-a48c01c3a55b84a43f768e4dd82836209539729b.zip
Cleanup up minify js script
- The slimit package is now widely available so make the script only rely on it and closure. Keeping closure as it makes the most compact and lints the javascript but it is not as easy to install as slimit.
Diffstat (limited to 'minify_web_js.py')
-rwxr-xr-xminify_web_js.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/minify_web_js.py b/minify_web_js.py
index da577d792..f2ff294eb 100755
--- a/minify_web_js.py
+++ b/minify_web_js.py
@@ -20,6 +20,7 @@ from __future__ import print_function
import fileinput
import fnmatch
import os
+import subprocess
import sys
@@ -35,21 +36,16 @@ def module_exists(module_name):
# Imports sorted by resulting file size.
if module_exists('closure'):
def minify_closure(file_in, file_out):
- import subprocess
try:
subprocess.check_call(['closure', '-W', 'QUIET',
'--js', file_in, '--js_output_file', file_out])
return True
except subprocess.CalledProcessError:
return False
-elif module_exists('slimit'):
+elif module_exists('sslimit'):
from slimit import minify
-elif module_exists('jsmin'):
- from jsmin import jsmin as minify
-elif module_exists('rjsmin'):
- from rjsmin import jsmin as minify
else:
- raise ImportError('Minifying WebUI JS requires slimit, jsmin or rjsmin')
+ raise ImportError('Requires "slimit" package for minifying WebUI files.')
def source_files_list(source_dir):
@@ -105,9 +101,8 @@ def minify_js_dir(source_dir):
return
concat_src_files(source_files, file_debug_js)
- if minify_file(file_debug_js, file_minified_js):
- print('Minified %s' % source_dir)
- else:
+ print('Minifying %s' % source_dir)
+ if not minify_file(file_debug_js, file_minified_js):
print('Error minifying %s' % source_dir)