kopia lustrzana https://github.com/c9/core
Revert "Revert "Fix "make static" for outplan""
rodzic
9ffaaf9367
commit
7ac30f2c66
|
@ -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, "");
|
||||
});
|
||||
}
|
||||
|
@ -391,8 +393,8 @@ function wrapUMD(module) {
|
|||
+ ' $build_deps$.module.define(name, [], function() { return $build_deps$.module.exports });\n'
|
||||
+ ' }\n'
|
||||
+ '}\n'
|
||||
+ 'define.amd = true;'
|
||||
+ module.source
|
||||
+ 'define.amd = true;\n'
|
||||
+ 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;
|
||||
|
||||
describe("The Module", function(){
|
||||
describe("The build module", function(){
|
||||
this.timeout(60000);
|
||||
|
||||
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) {
|
||||
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();
|
||||
});
|
||||
});
|
Ładowanie…
Reference in New Issue