Comparing version 0.5.0 to 0.5.1
@@ -11,5 +11,5 @@ var fs = require('fs') | ||
output: function(data, filename, callback) { | ||
output: function(data, filename, context, callback) { | ||
filename = (filename || 'ender') + '.js'; | ||
fs.writeFile(filename, data, encoding='utf8', function (err) { | ||
fs.writeFile(filename, (FILE.processComment(context) + data), encoding='utf8', function (err) { | ||
if (err) return console.log('somethign when wrong trying to write to ' + filename); | ||
@@ -21,2 +21,19 @@ console.log((filename + ' successfully built!').yellow); | ||
, uglify: function (source, out, filename, context, callback) { | ||
try { | ||
var tok = uglifyJS.parser.tokenizer(source) | ||
, c = tok() | ||
, ast = uglifyJS.parser.parse(source); | ||
ast = uglifyJS.uglify.ast_mangle(ast); | ||
ast = uglifyJS.uglify.ast_squeeze(ast); | ||
out(uglifyJS.uglify.gen_code(ast), (filename || 'ender') + '.min', context, function () { | ||
callback(); | ||
console.log("** WARNING: UglifyJS DISCARDS ALL COMMENTS **".red); | ||
}); | ||
} 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.') | ||
} | ||
} | ||
, enderSize: function (file, callback) { | ||
@@ -53,3 +70,3 @@ file = file || 'ender'; | ||
, assemble: function (packages, context, options, callback){ | ||
, assemble: function (packages, options, callback){ | ||
console.log('assembling packages...'); | ||
@@ -59,3 +76,3 @@ packages = packages.map(function (item) { | ||
}); | ||
FILE.processPackages(packages, context, options, function (result) { | ||
FILE.processPackages(packages, options, function (result) { | ||
callback && callback(result.join('\n\n')); | ||
@@ -66,10 +83,15 @@ }); | ||
, processComment: function (context) { | ||
return ("/*!\n" | ||
+ " * Ender: open module JavaScript framework\n" | ||
+ " * copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat)\n" | ||
+ " * https://ender.no.de\n" | ||
+ " * License MIT \n" | ||
+ " * Module's individual licenses still apply\n" | ||
+ " * Build: ender " + context + "\n" | ||
+ " */\n"); | ||
return ( | ||
[ "/*!" | ||
, " * =======================================================" | ||
, " * Ender: open module JavaScript framework" | ||
, " * copyright Dustin Diaz & Jacob Thornton 2011 (@ded @fat)" | ||
, " * https://ender.no.de" | ||
, " * License MIT" | ||
, " * Module's individual licenses still apply" | ||
, " * Build: ender " + context | ||
, " * =======================================================" | ||
, " */" | ||
].join('\n') + '\n\n' | ||
); | ||
} | ||
@@ -198,3 +220,3 @@ | ||
, processPackages: function (_packages, context, options, callback) { | ||
, processPackages: function (_packages, options, callback) { | ||
var result = [], i = 0; | ||
@@ -227,7 +249,2 @@ FILE.constructDependencyTree(_packages, 'node_modules', function (tree) { | ||
FILE.constructBridge(packagePath, packageJSON.ender, function (content) { | ||
if ((options.sans && !j) || (!options.sans && name == 'ender-js')) { | ||
// this is some straight up ¬33† b®u†å¬î†¥ | ||
source = source.replace(/\/\*[\s\S]+?\*\//g, ''); | ||
source = FILE.processComment(context) + source; | ||
} | ||
if (name !== 'ender-js' && !options.noop) { | ||
@@ -239,8 +256,4 @@ source = [ | ||
]; | ||
if (packageJSON.ender) { | ||
if (content) source.push(content.replace(/\n/g, '\n ')); | ||
} | ||
else { | ||
source.push('$.ender(module.exports);'); | ||
} | ||
if (packageJSON.ender) source.push(content.replace(/\n/g, '\n ')); | ||
else source.push('$.ender(module.exports);') | ||
source = source.join('\n\n ') + '\n\n}();'; | ||
@@ -250,5 +263,2 @@ } | ||
if (packages.length == ++i) { | ||
if (options.noop) { | ||
result.unshift(FILE.processComment(context)) | ||
} | ||
callback && callback(result); | ||
@@ -292,35 +302,2 @@ } | ||
, uglify: function (source, out, filename, callback) { | ||
try { | ||
var tok = uglifyJS.parser.tokenizer(source) | ||
, c = tok() | ||
, min = FILE.copywrite(c.comments_before) || '' | ||
, ast = uglifyJS.parser.parse(source); | ||
ast = uglifyJS.uglify.ast_mangle(ast); | ||
ast = uglifyJS.uglify.ast_squeeze(ast); | ||
min += uglifyJS.uglify.gen_code(ast); | ||
out(min, (filename || 'ender') + '.min', function () { | ||
callback(); | ||
console.log("** WARNING: UglifyJS DISCARDS ALL COMMENTS **".red); | ||
}); | ||
} 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.') | ||
} | ||
} | ||
, copywrite: function (comments) { //hack to retain uglify comments | ||
var ret = ""; | ||
for (var i = 0; i < comments.length; ++i) { | ||
var c = comments[i]; | ||
if (c.type == "comment1") { | ||
ret += "//" + c.value + "\n"; | ||
} else { | ||
ret += "/*" + c.value + "*/"; | ||
} | ||
} | ||
return ret + '\n'; | ||
} | ||
, removeDir: function (dir, callback) { | ||
@@ -327,0 +304,0 @@ rimraf(dir, function (err) { |
@@ -58,8 +58,8 @@ var colors = require('colors') | ||
} | ||
ENDER.file.assemble(_modules.concat(queue), context, options, function (source) { | ||
ENDER.file.assemble(_modules.concat(queue), options, function (source) { | ||
var built = 0, isComplete = function () { | ||
if (++built === 2) callback && callback(); | ||
}; | ||
ENDER.file.output(source, options.output || options.use, isComplete); | ||
ENDER.file.uglify(source, ENDER.file.output, options.output || options.use, isComplete); | ||
ENDER.file.output(source, options.output || options.use, context, isComplete); | ||
ENDER.file.uglify(source, ENDER.file.output, options.output || options.use, context, isComplete); | ||
}); | ||
@@ -96,8 +96,8 @@ }); | ||
context = [type, ENDER.util.unique(ENDER.cmd.normalize(modules)).join(' ')].join(' ') + (options.context || ''); | ||
ENDER.file.assemble(modules, context, options, function (source) { | ||
ENDER.file.assemble(modules, options, function (source) { | ||
var built = 0, isComplete = function () { | ||
if (++built === 2) callback && callback(); | ||
}; | ||
ENDER.file.output(source, options.output || options.use, isComplete); | ||
ENDER.file.uglify(source, ENDER.file.output, options.output || options.use, isComplete); | ||
ENDER.file.output(source, options.output || options.use, context, isComplete); | ||
ENDER.file.uglify(source, ENDER.file.output, options.output || options.use, context, isComplete); | ||
}); | ||
@@ -156,8 +156,8 @@ }); | ||
} | ||
ENDER.file.assemble(packages, context, options, function (source) { | ||
ENDER.file.assemble(packages, options, function (source) { | ||
var built = 0, isComplete = function () { | ||
if (++built === total) callback && callback(); | ||
}; | ||
ENDER.file.output(source, options.output, isComplete); | ||
ENDER.file.uglify(source, ENDER.file.output, options.output, isComplete); | ||
ENDER.file.output(source, options.output, context, isComplete); | ||
ENDER.file.uglify(source, ENDER.file.output, options.output, context, isComplete); | ||
}); | ||
@@ -164,0 +164,0 @@ }); |
{ | ||
"name": "ender", | ||
"description": "next level JavaScript modules", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"authors": ["Dustin Diaz <@ded>", "Jacob Thornton <@fat>"], | ||
@@ -6,0 +6,0 @@ "keywords": ["ender", "modules", "builder", "framework", "packager"], |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4368444
1335