From 8791a4f69615c4f31ad4cdb9f7fc91bcad7292c2 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 16 Jun 2013 18:45:51 -0700 Subject: [PATCH] Fix build by not counting pseudo private props as part of the `isVarUsed` result and accounting for `findWhere`. Former-commit-id: 974c3a31de0222b9239be0a5a9c4a7b5c5e41913 --- build.js | 16 +++++++++++----- test/test-build.js | 1 - 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build.js b/build.js index 1857cf35f..3781ad23d 100755 --- a/build.js +++ b/build.js @@ -357,7 +357,7 @@ ]; /** List of Lo-Dash methods */ - var lodashMethods = _.without.apply(_, [allMethods].concat(privateMethods)); + var lodashMethods = _.without.apply(_, [allMethods, 'findWhere'].concat(privateMethods)); /** List of Underscore methods */ var underscoreMethods = _.without.apply(_, [allMethods].concat(lodashOnlyMethods, privateMethods)); @@ -1062,8 +1062,13 @@ isShallow = isRemoved(source, 'runInContext'); } var indentA = isShallow ? ' {2}' : ' {2,4}', - indentB = isShallow ? ' {6}' : ' {6,8}', - snippet = source.replace(/^ *(?:\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/|\/\/.+)\n/gm, ''); + indentB = isShallow ? ' {6}' : ' {6,8}'; + + var snippet = source + // remove comments + .replace(/^ *(?:\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/|\/\/.+)\n/gm, '') + // remove pseudo private properties + .replace(/^ *lodash\._[^=]+=.+\n/gm, ''); var match = RegExp( '^(' + indentA + ')var ' + varName + ' *(?:|= *(?:.+?(?:|&&\\n[^;]+)|(?:\\w+\\(|[{[(]\\n)[\\s\\S]+?\\n\\1[^\\n ]+?));\\n|' + @@ -3109,7 +3114,7 @@ source = removeFunction(source, 'basicEach'); // remove `lodash._basicEach` pseudo property - source = source.replace(/^ *lodash\._basicEach *=.+\n/m, ''); + source = source.replace(/^ *lodash\._basicEach *=[\s\S]+?;\n/m, ''); // replace `basicEach` with `_.forOwn` in "Collections" methods source = source.replace(/\bbasicEach(?=\(collection)/g, 'forOwn'); @@ -3139,7 +3144,8 @@ else { // remove methods from the build allMethods.forEach(function(otherName) { - if (!_.contains(buildMethods, otherName)) { + if (!_.contains(buildMethods, otherName) && + !(otherName == 'findWhere' && !isUnderscore)) { source = removeFunction(source, otherName); } }); diff --git a/test/test-build.js b/test/test-build.js index 421d5b32b..c170e3d4c 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -318,7 +318,6 @@ 'unzip' ]; - /** List of all Lo-Dash methods */ var lodashMethods = allMethods.slice();