kopia lustrzana https://github.com/c9/core
Merge pull request +13569 from c9/revert-13568-revert-13542-none-dont-strip-copyright-comments
Fix "make static" for outplanpull/290/head
commit
95a5f59141
|
@ -113,6 +113,7 @@ module.exports = function(mains, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setModuleSource(mod, src, cb) {
|
function setModuleSource(mod, src, cb) {
|
||||||
|
src = src.replace(/\r\n/g, "\n"); // normalize windows newlines
|
||||||
if (cache)
|
if (cache)
|
||||||
cache.files[mod.file] = src;
|
cache.files[mod.file] = src;
|
||||||
mod.source = src;
|
mod.source = src;
|
||||||
|
@ -345,13 +346,14 @@ function removeUseStrict(module) {
|
||||||
module.source = module.source.replace(/['"]use strict['"];/g, "");
|
module.source = module.source.replace(/['"]use strict['"];/g, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var commentRe = /^(;)?(?:\s*(?:\/\/.+\n|\/\*(?:[^*]|\*(?!\/))*\*\/))+(?: *\n)?/gm;
|
||||||
function removeLicenceComments(module) {
|
function removeLicenceComments(module) {
|
||||||
if (/\.(js|jsx|css|less)/.test(module.path))
|
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) {
|
function removeLicenceCommentsKeepLines(module) {
|
||||||
if (/\.(js|jsx|css|less)/.test(module.path)) {
|
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, "");
|
return (start||"") + cm.replace(/.+/g, "");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -391,8 +393,8 @@ function wrapUMD(module) {
|
||||||
+ ' $build_deps$.module.define(name, [], function() { return $build_deps$.module.exports });\n'
|
+ ' $build_deps$.module.define(name, [], function() { return $build_deps$.module.exports });\n'
|
||||||
+ ' }\n'
|
+ ' }\n'
|
||||||
+ '}\n'
|
+ '}\n'
|
||||||
+ 'define.amd = true;'
|
+ 'define.amd = true;\n'
|
||||||
+ module.source
|
+ module.source + '\n'
|
||||||
+ '});';
|
+ '});';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
|
@ -17,7 +17,7 @@ require("amd-loader");
|
||||||
|
|
||||||
var build, options, pathConfig;
|
var build, options, pathConfig;
|
||||||
|
|
||||||
describe("The Module", function(){
|
describe("The build module", function(){
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
|
|
||||||
beforeEach(function(next) {
|
beforeEach(function(next) {
|
||||||
|
@ -63,7 +63,7 @@ describe("The Module", function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("test compile less", function(done) {
|
it("should compile less", function(done) {
|
||||||
build.buildSkin("ssh", "dark", pathConfig, function(err, result) {
|
build.buildSkin("ssh", "dark", pathConfig, function(err, result) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
|
||||||
|
@ -71,6 +71,28 @@ describe("The Module", function(){
|
||||||
assert(code);
|
assert(code);
|
||||||
done(err);
|
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();
|
||||||
});
|
});
|
||||||
});
|
});
|
Ładowanie…
Reference in New Issue