Merge remote-tracking branch 'origin/master' into all-ab-testing

Conflicts:
	npm-shrinkwrap.json
This commit is contained in:
Lennart Kats 2016-04-21 11:45:01 +00:00
commit 98bd065372
3 changed files with 36 additions and 9 deletions

View File

@ -29,7 +29,7 @@ module.exports = function(mains, opts) {
if (!opts.transforms)
opts.transforms = [];
opts.transforms.push(wrapUMD);
opts.transforms.push(removeLicenceComments, wrapUMD);
if (opts.pathConfig) {
opts.paths = opts.paths || opts.pathConfig.paths;
@ -113,6 +113,7 @@ module.exports = function(mains, opts) {
}
function setModuleSource(mod, src, cb) {
src = src.replace(/\r\n/g, "\n"); // normalize windows newlines
if (cache)
cache.files[mod.file] = src;
mod.source = src;
@ -345,13 +346,14 @@ function removeUseStrict(module) {
module.source = module.source.replace(/['"]use strict['"];/g, "");
}
var commentRe = /^(;)?(?:\s*(?:\/\/.+\n|\/\*(?:[^*]|\*(?!\/))*\*\/))+(?: *\n)?/gm;
function removeLicenceComments(module) {
if (/\.(js|jsx|css|less)/.test(module.path))
module.source = module.source.replace(/(?:(;)|\n|^)\s*\/\*[\d\D]*?\*\/|(\n|^)\s*\/\/.*/g, "$1");
module.source = module.source.replace(commentRe, "$1");
}
function removeLicenceCommentsKeepLines(module) {
if (/\.(js|jsx|css|less)/.test(module.path)) {
module.source = module.source.replace(/(?:(;)|\n|^)\s*\/\*[\d\D]*?\*\/|\n\s*\/\/.*/g, function(cm, start) {
module.source = module.source.replace(commentRe, function(cm, start) {
return (start||"") + cm.replace(/.+/g, "");
});
}
@ -410,4 +412,7 @@ function quote(str) {
}
module.exports.resolveModulePath = resolveModulePath;
module.exports.getSubmodules = getSubmodules;
module.exports.resolveModulePath = resolveModulePath;
module.exports.removeLicenceComments = removeLicenceComments;
module.exports.removeLicenceCommentsKeepLines = removeLicenceCommentsKeepLines;

View File

@ -1,7 +1,7 @@
{
"name": "c9",
"description": "New Cloud9 Client",
"version": "3.1.2264",
"version": "3.1.2299",
"author": "Ajax.org B.V. <info@ajax.org>",
"private": true,
"main": "bin/c9",

View File

@ -17,7 +17,7 @@ require("amd-loader");
var build, options, pathConfig;
describe("The Module", function(){
describe("The build module", function(){
this.timeout(60000);
beforeEach(function(next) {
@ -57,13 +57,13 @@ describe("The Module", function(){
var code = result.code;
assert(code.indexOf("<a:style><![CDATA[]]></a:style>" >= 0), "should have at least one stripped style");
//assert(!code.match(/<a:style><!\[CDATA\[[^\]]/), "should only have stripped styles");
assert(!code.match(/<a:style><!\[CDATA\[[^\]]/), "should only have stripped styles");
done();
});
});
it("test compile less", function(done) {
it("should compile less", function(done) {
build.buildSkin("ssh", "dark", pathConfig, function(err, result) {
if (err) return done(err);
@ -71,6 +71,28 @@ describe("The Module", function(){
assert(code);
done(err);
});
});
it("should remove comments", function(done) {
var removeLicenceComments = require("architect-build/module-deps").removeLicenceComments;
function remove(src) {
var module = { source: "" + src, path: ".js" };
removeLicenceComments(module);
return module.source;
}
assert.equal(remove("" + function() {
// 1
var a;
/***/ // hello
var x; // not removed
/* asd
*/
x += "he/*ll*/o" + a;
}) , function() {
var a;
var x; // not removed
x += "he/*ll*/o" + a;
});
done();
});
});