You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2023/01/12 15:12:32 UTC
[cordova-common] branch master updated: refactor: replace underscore w/ lodash module pkgs (#193)
This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-common.git
The following commit(s) were added to refs/heads/master by this push:
new e5d0899 refactor: replace underscore w/ lodash module pkgs (#193)
e5d0899 is described below
commit e5d0899bd7f6a28b4a0edc2f578566c6fd226b8a
Author: エリス <er...@users.noreply.github.com>
AuthorDate: Fri Jan 13 00:12:26 2023 +0900
refactor: replace underscore w/ lodash module pkgs (#193)
- _.extend -> lodash.assign
- _.isDate -> lodash.isdate
- _.isObject -> lodash.isobject
- _.zip -> lodash.zip
---
package-lock.json | 57 +++++++++++++++++++++++++++++++++++++----------
package.json | 7 ++++--
src/superspawn.js | 4 ++--
src/util/plist-helpers.js | 8 ++++---
src/util/xml-helpers.js | 7 +++---
5 files changed, 61 insertions(+), 22 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 5796cf9..7fe4e18 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -18,11 +18,14 @@
"fast-glob": "^3.2.2",
"fs-extra": "^9.0.0",
"glob": "^7.1.6",
+ "lodash.assign": "^4.2.0",
+ "lodash.isdate": "^4.0.1",
+ "lodash.isobject": "^3.0.2",
+ "lodash.zip": "^4.2.0",
"plist": "^3.0.1",
"q": "^1.5.1",
"read-chunk": "^3.2.0",
- "strip-bom": "^4.0.0",
- "underscore": "^1.9.2"
+ "strip-bom": "^4.0.0"
},
"devDependencies": {
"@cordova/eslint-config": "^3.0.0",
@@ -2802,12 +2805,32 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
+ "node_modules/lodash.assign": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz",
+ "integrity": "sha512-hFuH8TY+Yji7Eja3mGiuAxBqLagejScbG8GbG0j6o9vzn0YL14My+ktnqtZgFTosKymC9/44wP6s7xyuLfnClw=="
+ },
"node_modules/lodash.flattendeep": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz",
"integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==",
"dev": true
},
+ "node_modules/lodash.isdate": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/lodash.isdate/-/lodash.isdate-4.0.1.tgz",
+ "integrity": "sha512-hg5B1GD+R9egsBgMwmAhk+V53Us03TVvXT4dnyKugEfsD4QKuG9Wlyvxq8OGy2nu7qVGsh4DRSnMk33hoWBq/Q=="
+ },
+ "node_modules/lodash.isobject": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-3.0.2.tgz",
+ "integrity": "sha512-3/Qptq2vr7WeJbB4KHUSKlq8Pl7ASXi3UG6CMbBm8WRtXi8+GHm7mKaU3urfpSEzWe2wCIChs6/sdocUsTKJiA=="
+ },
+ "node_modules/lodash.zip": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz",
+ "integrity": "sha512-C7IOaBBK/0gMORRBd8OETNx3kmOkgIWIPvyDpZSCTwUrpYmgZwJkjZeOD8ww4xbOUOs4/attY+pciKvadNfFbg=="
+ },
"node_modules/make-dir": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
@@ -3958,11 +3981,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/underscore": {
- "version": "1.13.6",
- "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz",
- "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A=="
- },
"node_modules/universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
@@ -6265,12 +6283,32 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
+ "lodash.assign": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz",
+ "integrity": "sha512-hFuH8TY+Yji7Eja3mGiuAxBqLagejScbG8GbG0j6o9vzn0YL14My+ktnqtZgFTosKymC9/44wP6s7xyuLfnClw=="
+ },
"lodash.flattendeep": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz",
"integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==",
"dev": true
},
+ "lodash.isdate": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/lodash.isdate/-/lodash.isdate-4.0.1.tgz",
+ "integrity": "sha512-hg5B1GD+R9egsBgMwmAhk+V53Us03TVvXT4dnyKugEfsD4QKuG9Wlyvxq8OGy2nu7qVGsh4DRSnMk33hoWBq/Q=="
+ },
+ "lodash.isobject": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-3.0.2.tgz",
+ "integrity": "sha512-3/Qptq2vr7WeJbB4KHUSKlq8Pl7ASXi3UG6CMbBm8WRtXi8+GHm7mKaU3urfpSEzWe2wCIChs6/sdocUsTKJiA=="
+ },
+ "lodash.zip": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz",
+ "integrity": "sha512-C7IOaBBK/0gMORRBd8OETNx3kmOkgIWIPvyDpZSCTwUrpYmgZwJkjZeOD8ww4xbOUOs4/attY+pciKvadNfFbg=="
+ },
"make-dir": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz",
@@ -7121,11 +7159,6 @@
"which-boxed-primitive": "^1.0.2"
}
},
- "underscore": {
- "version": "1.13.6",
- "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz",
- "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A=="
- },
"universalify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
diff --git a/package.json b/package.json
index e36eeb6..4f85717 100644
--- a/package.json
+++ b/package.json
@@ -26,11 +26,14 @@
"fast-glob": "^3.2.2",
"fs-extra": "^9.0.0",
"glob": "^7.1.6",
+ "lodash.assign": "^4.2.0",
+ "lodash.isdate": "^4.0.1",
+ "lodash.isobject": "^3.0.2",
+ "lodash.zip": "^4.2.0",
"plist": "^3.0.1",
"q": "^1.5.1",
"read-chunk": "^3.2.0",
- "strip-bom": "^4.0.0",
- "underscore": "^1.9.2"
+ "strip-bom": "^4.0.0"
},
"devDependencies": {
"@cordova/eslint-config": "^3.0.0",
diff --git a/src/superspawn.js b/src/superspawn.js
index f20a8d8..2403458 100644
--- a/src/superspawn.js
+++ b/src/superspawn.js
@@ -19,7 +19,7 @@
const crossSpawn = require('cross-spawn');
const fs = require('fs-extra');
-const _ = require('underscore');
+const extend = require('lodash.assign');
const Q = require('q');
const events = require('./events');
const iswin32 = process.platform === 'win32';
@@ -73,7 +73,7 @@ exports.spawn = (cmd, args, opts) => {
}
if (opts.env) {
- spawnOpts.env = _.extend(_.extend({}, process.env), opts.env);
+ spawnOpts.env = extend(extend({}, process.env), opts.env);
}
if (opts.chmod && !iswin32) {
diff --git a/src/util/plist-helpers.js b/src/util/plist-helpers.js
index 901d39e..44f9111 100644
--- a/src/util/plist-helpers.js
+++ b/src/util/plist-helpers.js
@@ -18,7 +18,9 @@
*/
// contains PLIST utility functions
-const _ = require('underscore');
+const isObject = require('lodash.isobject');
+const isDate = require('lodash.isdate');
+const extend = require('lodash.assign');
const plist = require('plist');
// adds node to doc at selector
@@ -33,8 +35,8 @@ function graftPLIST (doc, xml, selector) {
} else {
// plist uses objects for <dict>. If we have two dicts we merge them instead of
// overriding the old one. See CB-6472
- const isDict = o => _.isObject(o) && !_.isDate(o); // arrays checked above
- if (isDict(node) && isDict(obj)) _.extend(obj, node);
+ const isDict = o => isObject(o) && !isDate(o); // arrays checked above
+ if (isDict(node) && isDict(obj)) extend(obj, node);
doc[selector] = obj;
}
diff --git a/src/util/xml-helpers.js b/src/util/xml-helpers.js
index 4b0f19b..da41265 100644
--- a/src/util/xml-helpers.js
+++ b/src/util/xml-helpers.js
@@ -25,7 +25,8 @@
const fs = require('fs-extra');
const path = require('path');
-const _ = require('underscore');
+const extend = require('lodash.assign');
+const zip = require('lodash.zip');
const et = require('elementtree');
const stripBom = require('strip-bom');
@@ -49,7 +50,7 @@ module.exports = {
one.len() === two.len() &&
String(one.text).trim() === String(two.text).trim() &&
attribMatch(one, two) &&
- _.zip(one.getchildren(), two.getchildren())
+ zip(one.getchildren(), two.getchildren())
.every(([c1, c2]) => module.exports.equalNodes(c1, c2));
},
@@ -158,7 +159,7 @@ module.exports = {
if (!target) return false;
if (xml.oldAttrib) {
- target.attrib = _.extend({}, xml.oldAttrib);
+ target.attrib = extend({}, xml.oldAttrib);
}
return true;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org