fix #2351 Minification fails on Windows

This commit is contained in:
nightwing 2015-02-12 19:46:21 +04:00
commit 0b20e4dc1d

View file

@ -307,6 +307,7 @@ function buildAceModuleInternal(opts, callback) {
ignore: opts.ignore || [], ignore: opts.ignore || [],
withRequire: false, withRequire: false,
basepath: ACE_HOME, basepath: ACE_HOME,
transforms: [normalizeLineEndings],
afterRead: [optimizeTextModules] afterRead: [optimizeTextModules]
}, write); }, write);
} }
@ -407,6 +408,10 @@ function getLoadedFileList(options, callback, result) {
callback(Object.keys(deps)); callback(Object.keys(deps));
} }
function normalizeLineEndings(module) {
module.source = module.source.replace(/\r\n/g, "\n");
}
function optimizeTextModules(sources) { function optimizeTextModules(sources) {
var textModules = {}; var textModules = {};
return sources.filter(function(pkg) { return sources.filter(function(pkg) {
@ -452,10 +457,10 @@ function optimizeTextModules(sources) {
if (/\.css$/.test(pkg.id)) { if (/\.css$/.test(pkg.id)) {
// remove unnecessary whitespace from css // remove unnecessary whitespace from css
input = input.replace(/\n\s+/g, "\n"); input = input.replace(/\n\s+/g, "\n");
input = '"' + input.replace(/\r?\n/g, '\\\n') + '"'; input = '"' + input.replace(/\n/g, '\\\n') + '"';
} else { } else {
// but don't break other files! // but don't break other files!
input = '"' + input.replace(/\r?\n/g, '\\n\\\n') + '"'; input = '"' + input.replace(/\n/g, '\\n\\\n') + '"';
} }
textModules[pkg.id] = input; textModules[pkg.id] = input;
} }