Merge branch 'nodeFixes' of github.com:bfrohs/UglifyJS2

Conflicts:
	tools/node.js
This commit is contained in:
Julian Lam 2014-05-30 08:17:02 -04:00
commit 66980e944f

View File

@ -53,12 +53,14 @@ exports.minify = function(files, options) {
options = UglifyJS.defaults(options, { options = UglifyJS.defaults(options, {
spidermonkey : false, spidermonkey : false,
outSourceMap : null, outSourceMap : null,
sourceMapURL : null,
sourceRoot : null, sourceRoot : null,
inSourceMap : null, inSourceMap : null,
fromString : false, fromString : false,
warnings : false, warnings : false,
mangle : {}, mangle : {},
output : null, output : null,
prefix : null,
compress : {} compress : {}
}); });
UglifyJS.base54.reset(); UglifyJS.base54.reset();
@ -76,6 +78,11 @@ exports.minify = function(files, options) {
var code = options.fromString var code = options.fromString
? file ? file
: fs.readFileSync(file, "utf8"); : fs.readFileSync(file, "utf8");
if (options.prefix !== null) {
file = file.replace(/^\/+/, "").split(/\/+/).slice(options.prefix).join("/");
}
sourcesContent[file] = code; sourcesContent[file] = code;
toplevel = UglifyJS.parse(code, { toplevel = UglifyJS.parse(code, {
filename: options.fromString ? "?" : file, filename: options.fromString ? "?" : file,
@ -132,7 +139,7 @@ exports.minify = function(files, options) {
} }
return { return {
code : stream + "", code : stream + (output.source_map ? "\n//@ sourceMappingURL=" + (options.sourceMapURL || options.outSourceMap) : ""),
map : output.source_map + "" map : output.source_map + ""
}; };
}; };