Upgrade to lodash 4 (#3315)

* Upgrade to lodash 4

* Fix incorrect require in babel-runtime/scripts

* Replace cloneDeep with cloneDeepWith where applicable
This commit is contained in:
Jordan Klassen
2016-05-13 14:15:14 -07:00
committed by Henry Zhu
parent 2607f35b9f
commit dc1f40540d
46 changed files with 76 additions and 76 deletions

View File

@@ -17,7 +17,7 @@
"convert-source-map": "^1.1.0",
"fs-readdir-recursive": "^0.1.0",
"glob": "^5.0.5",
"lodash": "^3.2.0",
"lodash": "^4.2.0",
"log-symbols": "^1.0.2",
"output-file-sync": "^1.1.0",
"path-exists": "^1.0.0",

View File

@@ -5,11 +5,11 @@ require("babel-core");
let pathExists = require("path-exists");
let commander = require("commander");
let kebabCase = require("lodash/string/kebabCase");
let kebabCase = require("lodash/kebabCase");
let options = require("babel-core").options;
let util = require("babel-core").util;
let uniq = require("lodash/array/uniq");
let each = require("lodash/collection/each");
let uniq = require("lodash/uniq");
let each = require("lodash/each");
let glob = require("glob");
each(options, function (option, key) {

View File

@@ -48,7 +48,7 @@ var assertTest = function (stdout, stderr, opts) {
if (opts.stderr) {
if (opts.stderrContains) {
assert.ok(_.contains(stderr, expectStderr), "stderr " + JSON.stringify(stderr) + " didn't contain " + JSON.stringify(expectStderr));
assert.ok(_.includes(stderr, expectStderr), "stderr " + JSON.stringify(stderr) + " didn't contain " + JSON.stringify(expectStderr));
} else {
chai.expect(stderr).to.equal(expectStderr, "stderr didn't match");
}
@@ -62,7 +62,7 @@ var assertTest = function (stdout, stderr, opts) {
if (opts.stdout) {
if (opts.stdoutContains) {
assert.ok(_.contains(stdout, expectStdout), "stdout " + JSON.stringify(stdout) + " didn't contain " + JSON.stringify(expectStdout));
assert.ok(_.includes(stdout, expectStdout), "stdout " + JSON.stringify(stdout) + " didn't contain " + JSON.stringify(expectStdout));
} else {
chai.expect(stdout).to.equal(expectStdout, "stdout didn't match");
}

View File

@@ -37,7 +37,7 @@
"convert-source-map": "^1.1.0",
"debug": "^2.1.1",
"json5": "^0.4.0",
"lodash": "^3.10.0",
"lodash": "^4.2.0",
"minimatch": "^2.0.3",
"path-exists": "^1.0.0",
"path-is-absolute": "^1.0.0",

View File

@@ -1,4 +1,4 @@
import isFunction from "lodash/lang/isFunction";
import isFunction from "lodash/isFunction";
import fs from "fs";
//

View File

@@ -1,9 +1,9 @@
import merge from "lodash/object/merge";
import mergeWith from "lodash/mergeWith";
export default function (dest?: Object, src?: Object): ?Object {
if (!dest || !src) return;
return merge(dest, src, function (a, b) {
return mergeWith(dest, src, function (a, b) {
if (b && Array.isArray(a)) {
let newArray = b.slice(0);

View File

@@ -4,7 +4,7 @@ import * as helpers from "babel-helpers";
import generator from "babel-generator";
import * as messages from "babel-messages";
import template from "babel-template";
import each from "lodash/collection/each";
import each from "lodash/each";
import * as t from "babel-types";
let buildUmdWrapper = template(`

View File

@@ -12,7 +12,7 @@ import { NodePath, Hub, Scope } from "babel-traverse";
import sourceMap from "source-map";
import generate from "babel-generator";
import codeFrame from "babel-code-frame";
import defaults from "lodash/object/defaults";
import defaults from "lodash/defaults";
import traverse from "babel-traverse";
import Logger from "./logger";
import Store from "../../store";

View File

@@ -9,8 +9,8 @@ import resolve from "../../../helpers/resolve";
import json5 from "json5";
import isAbsolute from "path-is-absolute";
import pathExists from "path-exists";
import cloneDeep from "lodash/lang/cloneDeep";
import clone from "lodash/lang/clone";
import cloneDeepWith from "lodash/cloneDeepWith";
import clone from "lodash/clone";
import merge from "../../../helpers/merge";
import config from "./config";
import removed from "./removed";
@@ -208,7 +208,7 @@ export default class OptionManager {
}
//
let opts = cloneDeep(rawOpts, (val) => {
let opts = cloneDeepWith(rawOpts, (val) => {
if (val instanceof Plugin) {
return val;
}

View File

@@ -1,5 +1,5 @@
import Plugin from "../plugin";
import sortBy from "lodash/collection/sortBy";
import sortBy from "lodash/sortBy";
export default new Plugin({
/**

View File

@@ -4,8 +4,8 @@ import OptionManager from "./file/options/option-manager";
import * as messages from "babel-messages";
import Store from "../store";
import traverse from "babel-traverse";
import assign from "lodash/object/assign";
import clone from "lodash/lang/clone";
import assign from "lodash/assign";
import clone from "lodash/clone";
const GLOBAL_VISITOR_PROPS = ["enter", "exit"];

View File

@@ -1,10 +1,10 @@
import escapeRegExp from "lodash/string/escapeRegExp";
import startsWith from "lodash/string/startsWith";
import isBoolean from "lodash/lang/isBoolean";
import escapeRegExp from "lodash/escapeRegExp";
import startsWith from "lodash/startsWith";
import isBoolean from "lodash/isBoolean";
import minimatch from "minimatch";
import contains from "lodash/collection/contains";
import isString from "lodash/lang/isString";
import isRegExp from "lodash/lang/isRegExp";
import includes from "lodash/includes";
import isString from "lodash/isString";
import isRegExp from "lodash/isRegExp";
import path from "path";
import slash from "slash";
@@ -17,7 +17,7 @@ export { inherits, inspect } from "util";
export function canCompile(filename: string, altExts?: Array<string>): boolean {
let exts = altExts || canCompile.EXTENSIONS;
let ext = path.extname(filename);
return contains(exts, ext);
return includes(exts, ext);
}
/**

View File

@@ -57,7 +57,7 @@ suite("util", function () {
assert.deepEqual(util.regexify(false), /.^/);
assert.deepEqual(util.regexify(null), /.^/);
assert.deepEqual(util.regexify(""), /.^/);
assert.deepEqual(util.regexify(["foo", "bar"]), /\x66oo|\x62ar/i);
assert.deepEqual(util.regexify(["foo", "bar"]), /foo|bar/i);
assert.deepEqual(util.regexify("foobar"), /(?:(?=.)foobar)/i);
assert.deepEqual(util.regexify(/foobar/), /foobar/);

View File

@@ -16,7 +16,7 @@
"babel-types": "^6.8.0",
"detect-indent": "^3.0.1",
"is-integer": "^1.0.4",
"lodash": "^3.10.1",
"lodash": "^4.2.0",
"repeating": "^1.1.3",
"source-map": "^0.5.0",
"trim-right": "^1.0.1"

View File

@@ -1,7 +1,7 @@
/* eslint max-len: 0 */
import isInteger from "is-integer";
import isNumber from "lodash/lang/isNumber";
import isNumber from "lodash/isNumber";
import * as t from "babel-types";
import * as n from "../node";

View File

@@ -1,6 +1,6 @@
import isBoolean from "lodash/lang/isBoolean";
import each from "lodash/collection/each";
import map from "lodash/collection/map";
import isBoolean from "lodash/isBoolean";
import each from "lodash/each";
import map from "lodash/map";
import * as t from "babel-types";
type WhitespaceObject = {

View File

@@ -9,6 +9,6 @@
"babel-runtime": "^6.0.0",
"babel-types": "^6.8.0",
"esutils": "^2.0.0",
"lodash": "^3.10.0"
"lodash": "^4.2.0"
}
}

View File

@@ -7,7 +7,7 @@
"main": "lib/index.js",
"dependencies": {
"babel-runtime": "^6.0.0",
"lodash": "^3.10.0",
"lodash": "^4.2.0",
"babel-types": "^6.8.0",
"babel-helper-function-name": "^6.8.0"
}

View File

@@ -1,8 +1,8 @@
/* eslint max-len: 0 */
import nameFunction from "babel-helper-function-name";
import each from "lodash/collection/each";
import has from "lodash/object/has";
import each from "lodash/each";
import has from "lodash/has";
import * as t from "babel-types";
function toKind(node: Object) {

View File

@@ -8,7 +8,7 @@
"main": "lib/index.js",
"dependencies": {
"babel-runtime": "^6.0.0",
"lodash": "^3.10.0",
"lodash": "^4.2.0",
"path-exists": "^1.0.0",
"trim-right": "^1.0.1",
"try-resolve": "^1.0.0"

View File

@@ -7,7 +7,7 @@
"main": "lib/index.js",
"dependencies": {
"babel-runtime": "^6.0.0",
"lodash": "^3.10.0",
"lodash": "^4.2.0",
"babel-types": "^6.8.0"
}
}

View File

@@ -1,4 +1,4 @@
import pull from "lodash/array/pull";
import pull from "lodash/pull";
import * as t from "babel-types";
export function is(node: Object, flag: string): boolean {

View File

@@ -16,6 +16,6 @@
"source-map": "^0.5.0",
"babel-code-frame": "^6.8.0",
"chai": "^2.2.0",
"lodash": "^3.10.0"
"lodash": "^4.2.0"
}
}

View File

@@ -121,12 +121,12 @@ export default function (
let suites = getFixtures(fixturesLoc);
for (let testSuite of suites) {
if (_.contains(suiteOpts.ignoreSuites, testSuite.title)) continue;
if (_.includes(suiteOpts.ignoreSuites, testSuite.title)) continue;
suite(name + "/" + testSuite.title, function () {
for (let task of testSuite.tests) {
if (_.contains(suiteOpts.ignoreTasks, task.title) ||
_.contains(suiteOpts.ignoreTasks, testSuite.title + "/" + task.title)) continue;
if (_.includes(suiteOpts.ignoreTasks, task.title) ||
_.includes(suiteOpts.ignoreTasks, testSuite.title + "/" + task.title)) continue;
test(task.title, !task.disabled && function () {
function runTask() {

View File

@@ -9,7 +9,7 @@
"babel-traverse": "^6.8.0",
"babel-types": "^6.8.0",
"babel-template": "^6.8.0",
"lodash": "^3.10.0",
"lodash": "^4.2.0",
"babel-runtime": "^6.0.0"
},
"keywords": [

View File

@@ -6,8 +6,8 @@ import type File from "../../../file";
import traverse from "babel-traverse";
import { visitor as tdzVisitor } from "./tdz";
import * as t from "babel-types";
import values from "lodash/object/values";
import extend from "lodash/object/extend";
import values from "lodash/values";
import extend from "lodash/extend";
import template from "babel-template";
export default function () {

View File

@@ -1,4 +1,4 @@
import last from "lodash/array/last"
import last from "lodash/last"
export default class Container {
last(key) {

View File

@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
var _last2 = require("lodash/array/last");
var _last2 = require("lodash/last");
var _last3 = babelHelpers.interopRequireDefault(_last2);

View File

@@ -10,7 +10,7 @@
],
"dependencies": {
"babel-runtime": "^6.0.0",
"lodash": "^3.9.3"
"lodash": "^4.2.0"
},
"devDependencies": {
"babel-helper-plugin-test-runner": "^6.8.0"

View File

@@ -1,6 +1,6 @@
/* eslint max-len: 0 */
import pull from "lodash/array/pull";
import pull from "lodash/pull";
export default function ({ types: t }) {
function isProtoKey(node) {

View File

@@ -80,7 +80,7 @@ require("babel-helper-transform-fixture-test-runner")(__dirname + "/fixtures/tra
}, {
}, function (opts, task) {
if (_.contains(task.exec.loc, "module.js")) {
if (_.includes(task.exec.loc, "module.js")) {
opts.plugins.push("transform-es2015-modules-commonjs");
} else {
opts.sourceType = "script";

View File

@@ -12,7 +12,7 @@
"babel-runtime": "^6.0.0",
"core-js": "^2.1.0",
"home-or-tmp": "^1.0.0",
"lodash": "^3.10.0",
"lodash": "^4.2.0",
"mkdirp": "^0.5.1",
"path-exists": "^1.0.0",
"source-map-support": "^0.2.10"

View File

@@ -1,9 +1,9 @@
import deepClone from "lodash/lang/cloneDeep";
import deepClone from "lodash/cloneDeep";
import sourceMapSupport from "source-map-support";
import * as registerCache from "./cache";
import extend from "lodash/object/extend";
import extend from "lodash/extend";
import * as babel from "babel-core";
import each from "lodash/collection/each";
import each from "lodash/each";
import { util, OptionManager } from "babel-core";
import fs from "fs";
import path from "path";

View File

@@ -1,5 +1,5 @@
var outputFile = require("output-file-sync");
var each = require("lodash/collection/each");
var each = require("lodash/each");
var fs = require("fs");
var _ = require("lodash");

View File

@@ -12,6 +12,6 @@
"babel-traverse": "^6.8.0",
"babel-types": "^6.8.0",
"babel-runtime": "^6.0.0",
"lodash": "^3.10.1"
"lodash": "^4.2.0"
}
}

View File

@@ -1,8 +1,8 @@
/* eslint max-len: 0 */
import cloneDeep from "lodash/lang/cloneDeep";
import assign from "lodash/object/assign";
import has from "lodash/object/has";
import cloneDeep from "lodash/cloneDeep";
import assign from "lodash/assign";
import has from "lodash/has";
import traverse from "babel-traverse";
import * as babylon from "babylon";
import * as t from "babel-types";

View File

@@ -16,7 +16,7 @@
"debug": "^2.2.0",
"globals": "^8.3.0",
"invariant": "^2.2.0",
"lodash": "^3.10.1",
"lodash": "^4.2.0",
"repeating": "^1.1.3"
}
}

View File

@@ -3,7 +3,7 @@
import TraversalContext from "./context";
import * as visitors from "./visitors";
import * as messages from "babel-messages";
import includes from "lodash/collection/includes";
import includes from "lodash/includes";
import * as t from "babel-types";
import * as cache from "./cache";

View File

@@ -6,7 +6,7 @@ import * as virtualTypes from "./lib/virtual-types";
import buildDebug from "debug";
import invariant from "invariant";
import traverse from "../index";
import assign from "lodash/object/assign";
import assign from "lodash/assign";
import Scope from "../scope";
import * as t from "babel-types";
import { path as pathCache } from "../cache";

View File

@@ -1,7 +1,7 @@
// This file contains methods responsible for introspecting the current path for certain values.
import type NodePath from "./index";
import includes from "lodash/collection/includes";
import includes from "lodash/includes";
import * as t from "babel-types";
/**

View File

@@ -1,11 +1,11 @@
/* eslint max-len: 0 */
import includes from "lodash/collection/includes";
import includes from "lodash/includes";
import repeating from "repeating";
import Renamer from "./lib/renamer";
import type NodePath from "../path";
import traverse from "../index";
import defaults from "lodash/object/defaults";
import defaults from "lodash/defaults";
import * as messages from "babel-messages";
import Binding from "./binding";
import globals from "globals";

View File

@@ -1,7 +1,7 @@
import * as virtualTypes from "./path/lib/virtual-types";
import * as messages from "babel-messages";
import * as t from "babel-types";
import clone from "lodash/lang/clone";
import clone from "lodash/clone";
/**
* explode() will take a visitor object with all of the various shorthands

View File

@@ -11,7 +11,7 @@
"babel-runtime": "^6.0.0",
"babel-traverse": "^6.8.0",
"esutils": "^2.0.2",
"lodash": "^3.10.1",
"lodash": "^4.2.0",
"to-fast-properties": "^1.0.1"
}
}

View File

@@ -1,7 +1,7 @@
import isPlainObject from "lodash/lang/isPlainObject";
import isNumber from "lodash/lang/isNumber";
import isRegExp from "lodash/lang/isRegExp";
import isString from "lodash/lang/isString";
import isPlainObject from "lodash/isPlainObject";
import isNumber from "lodash/isNumber";
import isRegExp from "lodash/isRegExp";
import isString from "lodash/isString";
import type { Scope } from "babel-traverse";
import * as t from "./index";

View File

@@ -1,8 +1,8 @@
import toFastProperties from "to-fast-properties";
import compact from "lodash/array/compact";
import loClone from "lodash/lang/clone";
import each from "lodash/collection/each";
import uniq from "lodash/array/uniq";
import compact from "lodash/compact";
import loClone from "lodash/clone";
import each from "lodash/each";
import uniq from "lodash/uniq";
let t = exports;