mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Fix failing build tests.
Former-commit-id: c4673ee77f6750500e0f0a1adaf359108db89932
This commit is contained in:
109
build.js
109
build.js
@@ -3333,14 +3333,16 @@
|
|||||||
|
|
||||||
// inline all functions defined with `createIterator`
|
// inline all functions defined with `createIterator`
|
||||||
_.functions(lodash).forEach(function(methodName) {
|
_.functions(lodash).forEach(function(methodName) {
|
||||||
// strip leading underscores to match pseudo private functions
|
if (!(isUnderscore && isLodashMethod(methodName))) {
|
||||||
var reFunc = RegExp('^( *)(var ' + methodName.replace(/^_/, '') + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n', 'm');
|
// strip leading underscores to match pseudo private functions
|
||||||
if (reFunc.test(source)) {
|
var reFunc = RegExp('^( *)(var ' + methodName.replace(/^_/, '') + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n', 'm');
|
||||||
// extract, format, and inject the compiled function's source code
|
if (reFunc.test(source)) {
|
||||||
source = source.replace(reFunc, function(match, indent, left) {
|
// extract, format, and inject the compiled function's source code
|
||||||
return (indent + left) +
|
source = source.replace(reFunc, function(match, indent, left) {
|
||||||
cleanupCompiled(getFunctionSource(lodash[methodName], indent)) + ';\n';
|
return (indent + left) +
|
||||||
});
|
cleanupCompiled(getFunctionSource(lodash[methodName], indent)) + ';\n';
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -3423,46 +3425,48 @@
|
|||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
source = removeFromCreateIterator(source, 'support');
|
|
||||||
|
|
||||||
// inline `iteratorTemplate` template
|
source = removeFromCreateIterator(source, 'support');
|
||||||
source = source.replace(getIteratorTemplate(source), function(match) {
|
|
||||||
var indent = getIndent(match),
|
|
||||||
snippet = cleanupCompiled(getFunctionSource(lodash._iteratorTemplate, indent));
|
|
||||||
|
|
||||||
// prepend data object references to property names to avoid having to
|
// inline `iteratorTemplate` template
|
||||||
// use a with-statement
|
source = source.replace(getIteratorTemplate(source), function(match) {
|
||||||
iteratorOptions.forEach(function(prop) {
|
var indent = getIndent(match),
|
||||||
if (prop !== 'support') {
|
snippet = cleanupCompiled(getFunctionSource(lodash._iteratorTemplate, indent));
|
||||||
snippet = snippet.replace(RegExp('([^\\w.])' + prop + '\\b', 'g'), '$1obj.' + prop);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// remove unnecessary code
|
// prepend data object references to property names to avoid having to
|
||||||
snippet = snippet
|
// use a with-statement
|
||||||
.replace(/var __t.+/, "var __p = '';")
|
iteratorOptions.forEach(function(prop) {
|
||||||
.replace(/function print[^}]+}/, '')
|
if (prop !== 'support') {
|
||||||
.replace(/'(?:\\n|\s)+'/g, "''")
|
snippet = snippet.replace(RegExp('([^\\w.])' + prop + '\\b', 'g'), '$1obj.' + prop);
|
||||||
.replace(/__p *\+= *' *';/g, '')
|
}
|
||||||
.replace(/\s*\+\s*'';/g, ';')
|
|
||||||
.replace(/(__p *\+= *)' *' *\+/g, '$1')
|
|
||||||
.replace(/\(\(__t *= *\( *([\s\S]+?) *\)\) *== *null *\? *'' *: *__t\)/g, '($1)');
|
|
||||||
|
|
||||||
// remove the with-statement
|
|
||||||
snippet = snippet.replace(/ *with *\(.+?\) *{/, '\n').replace(/}([^}]*}[^}]*$)/, '$1');
|
|
||||||
|
|
||||||
// minor cleanup
|
|
||||||
snippet = snippet
|
|
||||||
.replace(/obj\s*\|\|\s*\(obj *= *{}\);/, '')
|
|
||||||
.replace(/var __p = '';\s*__p \+=/, 'var __p =');
|
|
||||||
|
|
||||||
// remove comments, including sourceURLs
|
|
||||||
snippet = snippet.replace(/\s*\/\/.*(?:\n|$)/g, '');
|
|
||||||
|
|
||||||
return indent + 'var iteratorTemplate = ' + snippet + ';\n';
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
// remove unnecessary code
|
||||||
|
snippet = snippet
|
||||||
|
.replace(/var __t.+/, "var __p = '';")
|
||||||
|
.replace(/function print[^}]+}/, '')
|
||||||
|
.replace(/'(?:\\n|\s)+'/g, "''")
|
||||||
|
.replace(/__p *\+= *' *';/g, '')
|
||||||
|
.replace(/\s*\+\s*'';/g, ';')
|
||||||
|
.replace(/(__p *\+= *)' *' *\+/g, '$1')
|
||||||
|
.replace(/\(\(__t *= *\( *([\s\S]+?) *\)\) *== *null *\? *'' *: *__t\)/g, '($1)');
|
||||||
|
|
||||||
|
// remove the with-statement
|
||||||
|
snippet = snippet.replace(/ *with *\(.+?\) *{/, '\n').replace(/}([^}]*}[^}]*$)/, '$1');
|
||||||
|
|
||||||
|
// minor cleanup
|
||||||
|
snippet = snippet
|
||||||
|
.replace(/obj\s*\|\|\s*\(obj *= *{}\);/, '')
|
||||||
|
.replace(/var __p = '';\s*__p \+=/, 'var __p =');
|
||||||
|
|
||||||
|
// remove comments, including sourceURLs
|
||||||
|
snippet = snippet.replace(/\s*\/\/.*(?:\n|$)/g, '');
|
||||||
|
|
||||||
|
// replace `iteratorTemplate` assignment
|
||||||
|
snippet = indent + 'var iteratorTemplate = ' + snippet + ';\n';
|
||||||
|
|
||||||
|
return snippet;
|
||||||
|
});
|
||||||
|
|
||||||
// remove methods from the build
|
// remove methods from the build
|
||||||
allMethods.forEach(function(otherName) {
|
allMethods.forEach(function(otherName) {
|
||||||
@@ -3597,6 +3601,9 @@
|
|||||||
source = source.replace(/\blodash\.(createCallback\()\b/g, '$1');
|
source = source.replace(/\blodash\.(createCallback\()\b/g, '$1');
|
||||||
}
|
}
|
||||||
if (isNoDep) {
|
if (isNoDep) {
|
||||||
|
// remove all horizontal rule comment separators
|
||||||
|
source = source.replace(/^ *\/\*-+\*\/\n/gm, '');
|
||||||
|
|
||||||
_.each(buildMethods, function(methodName) {
|
_.each(buildMethods, function(methodName) {
|
||||||
_.each(getAliases(methodName), function(alias) {
|
_.each(getAliases(methodName), function(alias) {
|
||||||
source = removeFunction(source, alias);
|
source = removeFunction(source, alias);
|
||||||
@@ -3607,8 +3614,12 @@
|
|||||||
source = removeVar(source, varName);
|
source = removeVar(source, varName);
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove all horizontal rule comment separators
|
if (!isAMD && !isCommonJS && !isGlobal && !isNode) {
|
||||||
source = source.replace(/^ *\/\*-+\*\/\n/gm, '');
|
source = removeFunction(source, 'lodash');
|
||||||
|
source = removeLodashWrapper(source);
|
||||||
|
source = removePseudoPrivates(source);
|
||||||
|
source = removeMethodAssignments(source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isExcluded('bind')) {
|
if (isExcluded('bind')) {
|
||||||
@@ -3728,12 +3739,6 @@
|
|||||||
if (_.size(source.match(/\bfreeExports\b/g)) < 2) {
|
if (_.size(source.match(/\bfreeExports\b/g)) < 2) {
|
||||||
source = removeVar(source, 'freeExports');
|
source = removeVar(source, 'freeExports');
|
||||||
}
|
}
|
||||||
if (!isAMD && !isCommonJS && !isGlobal && !isNode) {
|
|
||||||
source = removeFunction(source, 'lodash');
|
|
||||||
source = removeLodashWrapper(source);
|
|
||||||
source = removePseudoPrivates(source);
|
|
||||||
source = removeMethodAssignments(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
debugSource = cleanupSource(source);
|
debugSource = cleanupSource(source);
|
||||||
source = debugSource;
|
source = debugSource;
|
||||||
|
|||||||
@@ -1363,16 +1363,11 @@
|
|||||||
|
|
||||||
commands.forEach(function(command) {
|
commands.forEach(function(command) {
|
||||||
asyncTest('`lodash modern include=each ' + command +'`', function() {
|
asyncTest('`lodash modern include=each ' + command +'`', function() {
|
||||||
var start = _.after(2, _.once(QUnit.start));
|
var start = _.once(QUnit.start);
|
||||||
|
|
||||||
build(['-s', 'modern', 'include=each', command], function(data) {
|
build(['-s', 'modern', 'include=each', command], function(data) {
|
||||||
var basename = path.basename(data.outputPath, '.js'),
|
var basename = path.basename(data.outputPath, '.js');
|
||||||
context = createContext();
|
strictEqual(/function createCallback\b/.test(data.source), false, basename);
|
||||||
|
|
||||||
vm.runInContext(data.source, context);
|
|
||||||
var lodash = context._;
|
|
||||||
|
|
||||||
deepEqual(_.functions(lodash), ['each', 'forEach'], basename);
|
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1582,12 +1577,11 @@
|
|||||||
'include=each,filter,map',
|
'include=each,filter,map',
|
||||||
'include=once plus=bind,Chaining',
|
'include=once plus=bind,Chaining',
|
||||||
'category=collections,functions',
|
'category=collections,functions',
|
||||||
'backbone legacy category=utilities minus=first,last',
|
'backbone category=utilities minus=first,last',
|
||||||
'legacy include=defer',
|
'legacy include=defer',
|
||||||
'legacy underscore',
|
|
||||||
'modern strict include=isArguments,isArray,isFunction,isPlainObject,key',
|
'modern strict include=isArguments,isArray,isFunction,isPlainObject,key',
|
||||||
'underscore include=debounce,throttle plus=after minus=throttle',
|
'underscore include=debounce,throttle plus=after minus=throttle',
|
||||||
'underscore mobile strict category=functions exports=amd,global plus=pick,uniq',
|
'underscore strict category=functions exports=amd,global plus=pick,uniq',
|
||||||
]
|
]
|
||||||
.concat(
|
.concat(
|
||||||
allMethods.map(function(methodName) {
|
allMethods.map(function(methodName) {
|
||||||
@@ -1595,27 +1589,14 @@
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
commands.forEach(function(origCommand) {
|
var reNonCombinable = /\b(?:backbone|legacy|mobile|modern|underscore)\b/;
|
||||||
_.times(4, function(index) {
|
|
||||||
var command = origCommand;
|
|
||||||
|
|
||||||
if (index == 1) {
|
commands.forEach(function(origCommand) {
|
||||||
if (/\b(?:legacy|mobile)\b/.test(command)) {
|
_.each(['', 'mobile', 'modern', 'underscore'], function(otherCommand) {
|
||||||
return;
|
var command = (otherCommand + ' ' + origCommand).trim();
|
||||||
}
|
if ((otherCommand && reNonCombinable.test(origCommand)) ||
|
||||||
command = 'mobile ' + command;
|
(otherCommand == 'underscore' && /\bcategory\b/.test(origCommand))) {
|
||||||
}
|
return;
|
||||||
else if (index == 2) {
|
|
||||||
if (/\b(?:legacy|modern)\b/.test(command)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
command = 'modern ' + command;
|
|
||||||
}
|
|
||||||
else if (index == 3) {
|
|
||||||
if (/\b(?:category|legacy|underscore)\b/.test(command)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
command = 'underscore ' + command;
|
|
||||||
}
|
}
|
||||||
asyncTest('`lodash ' + command +'`', function() {
|
asyncTest('`lodash ' + command +'`', function() {
|
||||||
var start = _.after(2, _.once(QUnit.start));
|
var start = _.after(2, _.once(QUnit.start));
|
||||||
|
|||||||
Reference in New Issue
Block a user