Browse Source

Upgrade `UglifyPlugin` to use 2.3.5 version of uglify. (Issue #214)

- Fix expected files in uglify tests
- Use proper configuration for copyright retention
main
Lakshmi Vyasarajan 11 years ago
parent
commit
2046f13ab3
7 changed files with 57 additions and 33 deletions
  1. +6
    -0
      CHANGELOG.rst
  2. +1
    -1
      README.rst
  3. +17
    -15
      hyde/ext/plugins/js.py
  4. +9
    -8
      hyde/tests/ext/test_uglify.py
  5. +19
    -4
      hyde/tests/ext/uglify/expected-jquery-nc.js
  6. +4
    -4
      hyde/tests/ext/uglify/expected-jquery.js
  7. +1
    -1
      hyde/version.py

+ 6
- 0
CHANGELOG.rst View File

@@ -1,3 +1,9 @@
Version 0.8.7a3
============================================================

* Upgrade `UglifyPlugin` to use 2.3.5 version of uglify. (Issue #214)


Version 0.8.7a2
============================================================



+ 1
- 1
README.rst View File

@@ -1,4 +1,4 @@
Version 0.8.7a1
Version 0.8.7a3

A brand new **hyde**
====================


+ 17
- 15
hyde/ext/plugins/js.py View File

@@ -53,21 +53,24 @@ class UglifyPlugin(CLTransformer):
return

supported = [
"source-map",
"source-map-root",
"source-map-url",
"in-source-map",
"screw-ie8",
"expr",
("prefix", "p"),
("beautify", "b"),
("indent", "i"),
("quote-keys", "q"),
("mangle-toplevel", "mt"),
("no-mangle", "nm"),
("no-squeeze", "ns"),
"no-seqs",
"no-dead-code",
("no-copyright", "nc"),
"overwrite",
"verbose",
"unsafe",
"max-line-len",
"reserved-names",
"ascii"
("mangle", "m"),
("reserved", "r"),
("compress", "c"),
("define", "d"),
("enclose", "e"),
"comments",
"stats",
"wrap",
"lint",
"verbose"
]

uglify = self.app
@@ -76,7 +79,6 @@ class UglifyPlugin(CLTransformer):
args = [unicode(uglify)]
args.extend(self.process_args(supported))
args.extend(["-o", unicode(target), unicode(source)])

self.call_app(args)
out = target.read_all()
return out


+ 9
- 8
hyde/tests/ext/test_uglify.py View File

@@ -9,6 +9,7 @@ from hyde.generator import Generator
from hyde.site import Site

from fswrap import File, Folder
from hyde.tests.util import assert_no_diff

UGLIFY_SOURCE = File(__file__).parent.child_folder('uglify')
TEST_SITE = File(__file__).parent.parent.child_folder('_test')
@@ -38,25 +39,26 @@ class TestUglify(object):
gen.generate_resource_at_path(source)

assert target.exists
expected = File(UGLIFY_SOURCE.child('expected-jquery.js'))
expected = UGLIFY_SOURCE.child_file('expected-jquery.js').read_all()
# TODO: Very fragile. Better comparison needed.
assert target.read_all() == expected.read_all()
text = target.read_all()
assert_no_diff(expected, text)

def test_uglify_with_extra_options(self):
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.js.UglifyPlugin']
s.config.mode = "production"
s.config.uglify = Expando(dict(args={"nc":""}))
s.config.uglify = Expando(dict(args={"comments":"/http\:\/\/jquery.org\/license/"}))
source = TEST_SITE.child('content/media/js/jquery.js')
target = File(Folder(s.config.deploy_root_path).child('media/js/jquery.js'))
gen = Generator(s)
gen.generate_resource_at_path(source)

assert target.exists
expected = File(UGLIFY_SOURCE.child('expected-jquery-nc.js'))
expected = UGLIFY_SOURCE.child_file('expected-jquery-nc.js').read_all()
# TODO: Very fragile. Better comparison needed.
text = target.read_all()
assert text.startswith("(function(")
assert_no_diff(expected, text)

def test_no_uglify_in_dev_mode(self):
s = Site(TEST_SITE)
@@ -68,10 +70,9 @@ class TestUglify(object):
gen.generate_resource_at_path(source)

assert target.exists
expected = File(UGLIFY_SOURCE.child('jquery.js'))
expected = UGLIFY_SOURCE.child_file('jquery.js').read_all()
# TODO: Very fragile. Better comparison needed.
text = target.read_all()
expected = expected.read_all()
assert text == expected
assert_no_diff(expected, text)



+ 19
- 4
hyde/tests/ext/uglify/expected-jquery-nc.js
File diff suppressed because it is too large
View File


+ 4
- 4
hyde/tests/ext/uglify/expected-jquery.js
File diff suppressed because it is too large
View File


+ 1
- 1
hyde/version.py View File

@@ -2,4 +2,4 @@
"""
Handles hyde version.
"""
__version__ = '0.8.7a2'
__version__ = '0.8.7a3'

Loading…
Cancel
Save