mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 03:55:43 +00:00
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.
This commit is contained in:
parent
7468078b71
commit
a48c01c3a5
@ -20,6 +20,7 @@ from __future__ import print_function
|
|||||||
import fileinput
|
import fileinput
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
@ -35,21 +36,16 @@ def module_exists(module_name):
|
|||||||
# Imports sorted by resulting file size.
|
# Imports sorted by resulting file size.
|
||||||
if module_exists('closure'):
|
if module_exists('closure'):
|
||||||
def minify_closure(file_in, file_out):
|
def minify_closure(file_in, file_out):
|
||||||
import subprocess
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['closure', '-W', 'QUIET',
|
subprocess.check_call(['closure', '-W', 'QUIET',
|
||||||
'--js', file_in, '--js_output_file', file_out])
|
'--js', file_in, '--js_output_file', file_out])
|
||||||
return True
|
return True
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return False
|
return False
|
||||||
elif module_exists('slimit'):
|
elif module_exists('sslimit'):
|
||||||
from slimit import minify
|
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:
|
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):
|
def source_files_list(source_dir):
|
||||||
@ -105,9 +101,8 @@ def minify_js_dir(source_dir):
|
|||||||
return
|
return
|
||||||
|
|
||||||
concat_src_files(source_files, file_debug_js)
|
concat_src_files(source_files, file_debug_js)
|
||||||
if minify_file(file_debug_js, file_minified_js):
|
print('Minifying %s' % source_dir)
|
||||||
print('Minified %s' % source_dir)
|
if not minify_file(file_debug_js, file_minified_js):
|
||||||
else:
|
|
||||||
print('Error minifying %s' % source_dir)
|
print('Error minifying %s' % source_dir)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user