Permalink
Browse files

make `ender info` show gzipped minified file size

  • Loading branch information...
1 parent 97aa526 commit 76961673be2a29e893d8d3dc9b97e3faf8b169a6 @rvagg rvagg committed Feb 9, 2012
Showing with 21 additions and 11 deletions.
  1. +18 −8 lib/ender.file.js
  2. +1 −1 package.json
  3. +2 −2 test/test.js
View
@@ -22,7 +22,7 @@ ENDER.file = module.exports = {
)
}
-, uglify: function (source, filename, context, options, callback) {
+, uglifySource: function (source, callback) {
try {
var comments = []
, token = '"Ender: preserved comment block"'
@@ -35,9 +35,6 @@ ENDER.file = module.exports = {
, ast
, c
- filename = filename || 'ender'
- filename += '.min'
-
source = source.replace(reMultiComments, function(comment) {
comments.push(comment)
return ';' + token + ';'
@@ -54,13 +51,25 @@ ENDER.file = module.exports = {
return '\n' + comments.shift() + '\n'
})
- ENDER.file.output(source, filename, context, options, callback)
+ callback(null, source)
} catch (e) {
- console.log('Ender was unable to minify your library with UglifyJS!'.red)
- console.log('This usually means you have a js syntax error in one of your packages.')
+ callback(e)
}
}
+, uglify: function (source, filename, context, options, callback) {
+ ENDER.file.uglifySource(source, function (err, source) {
+ if (err) {
+ console.log('Ender was unable to minify your library with UglifyJS!'.red)
+ return console.log('This usually means you have a js syntax error in one of your packages.')
+ }
+
+ filename = filename || 'ender'
+ filename += '.min'
+ ENDER.file.output(source, filename, context, options, callback)
+ })
+ }
+
, output: function(data, filename, context, options, callback) {
filename = filename || 'ender'
filename += '.js'
@@ -84,6 +93,7 @@ ENDER.file = module.exports = {
if (exists) {
async.waterfall([
async.apply(fs.readFile, file, 'utf-8')
+ , ENDER.file.uglifySource
, ENDER.file.gzip
, writeSize
])
@@ -97,7 +107,7 @@ ENDER.file = module.exports = {
function writeSize (data) {
console.log('Your current build type is ' + ('"' + type + '"').yellow)
- console.log('Your current library size is ' + ((Math.round((data.length/1024) * 10) / 10) + '').yellow + ' kB\n')
+ console.log('Your current minified and compressed library size is ' + ((Math.round((data.length/1024) * 10) / 10) + '').yellow + ' kB\n')
callback && callback()
}
}
View
@@ -1,7 +1,7 @@
{
"name": "ender"
, "description": "next level JavaScript modules"
- , "version": "0.8.3"
+ , "version": "0.8.4"
, "authors": [
"Jacob Thornton <jacob@twitter.com> (https://github.com/fat)"
, "Dustin Diaz <dustin@obvious.com> (https://github.com/ded)"
View
@@ -48,7 +48,7 @@ sink('ENDER - DEPENDENCIES', function (test, ok, before, after) {
fs.readFile('./ender.js', 'utf-8', function (err, data) {
if (err) ok(false, 'error reading ender.js');
ok(new RegExp(cmd).test(data), 'includes correct build command in comment');
- ok(data.match(/http:\/\/documentcloud.github.com\/backbone/g).length == 1, 'backbone was built into ender');
+ ok(data.match(/http:\/\/backbonejs.org/g).length == 1, 'backbone was built into ender');
ok(data.match(/http:\/\/documentcloud.github.com\/underscore/g).length == 1, 'undersore was built into ender');
});
});
@@ -357,4 +357,4 @@ sink('ENDER - NOOP', function (test, ok, before, after) {
});
-spec.start();
+spec.start();

0 comments on commit 7696167

Please sign in to comment.