pluginfw: Replace `slide.asyncMap()` with `Promise.all()`

pull/4675/head^2
Richard Hansen 2021-02-04 01:06:51 -05:00 committed by John McLear
parent 746cc8cc34
commit fdaacc44c8
4 changed files with 12 additions and 20 deletions

11
package-lock.json generated
View File

@ -862,7 +862,6 @@
"resolve": "1.1.7",
"security": "1.0.0",
"semver": "5.6.0",
"slide": "1.1.6",
"socket.io": "^2.4.1",
"terser": "^4.7.0",
"threads": "^1.4.0",
@ -10544,6 +10543,11 @@
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.2.tgz",
"integrity": "sha512-T4tewALS3+qsrpGI/8dqNMLIVdq/g/85U98HPMa6F0m6xTbvhXU6RCQLqPH3+SlomNV/LdY6RXEbBpMH6EOJnA=="
},
"wtfnode": {
"version": "0.8.4",
"resolved": "https://registry.npmjs.org/wtfnode/-/wtfnode-0.8.4.tgz",
"integrity": "sha512-64GEKtMt/MUBuAm+8kHqP74ojjafzu00aT0JKsmkIwYmjRQ/odO0yhbzKLm+Z9v1gMla+8dwITRKzTAlHsB+Og=="
},
"xml2js": {
"version": "0.4.23",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
@ -10578,11 +10582,6 @@
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="
},
"wtfnode": {
"version": "0.8.4",
"resolved": "https://registry.npmjs.org/wtfnode/-/wtfnode-0.8.4.tgz",
"integrity": "sha512-64GEKtMt/MUBuAm+8kHqP74ojjafzu00aT0JKsmkIwYmjRQ/odO0yhbzKLm+Z9v1gMla+8dwITRKzTAlHsB+Og=="
},
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",

5
src/package-lock.json generated
View File

@ -7680,11 +7680,6 @@
}
}
},
"slide": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz",
"integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc="
},
"socket.io": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.4.1.tgz",

View File

@ -64,7 +64,6 @@
"resolve": "1.1.7",
"security": "1.0.0",
"semver": "5.6.0",
"slide": "1.1.6",
"socket.io": "^2.4.1",
"terser": "^4.7.0",
"threads": "^1.4.0",

View File

@ -93,9 +93,9 @@ as far as the left-most node_modules folder.
const npm = require('npm/lib/npm.js');
const fs = require('graceful-fs');
const path = require('path');
const asyncMap = require('slide').asyncMap;
const semver = require('semver');
const log = require('log4js').getLogger('pluginfw');
const util = require('util');
let fuSeen = [];
let riSeen = [];
@ -178,14 +178,13 @@ const readInstalled_ = (folder, parent, name, reqver, depth, maxDepth, cb) => {
rpSeen[real] = obj;
obj.depth = depth;
if (depth >= maxDepth) return cb(null, obj);
asyncMap(installed, (pkg, cb) => {
Promise.all(installed.map(async (pkg) => {
let rv = obj.dependencies[pkg];
if (!rv && obj.devDependencies) rv = obj.devDependencies[pkg];
readInstalled_(path.resolve(folder, `node_modules/${pkg}`)
, obj, pkg, obj.dependencies[pkg], depth + 1, maxDepth
, cb);
}, (er, installedData) => {
if (er) return cb(er);
const dir = path.resolve(folder, `node_modules/${pkg}`);
const deps = obj.dependencies[pkg];
return await util.promisify(readInstalled_)(dir, obj, pkg, deps, depth + 1, maxDepth);
})).then((installedData) => {
installedData.forEach((dep) => {
obj.dependencies[dep.realName] = dep;
});
@ -200,7 +199,7 @@ const readInstalled_ = (folder, parent, name, reqver, depth, maxDepth, cb) => {
});
}
return cb(null, obj);
});
}, (err) => cb(err || new Error(err)));
};
fs.readdir(path.resolve(folder, 'node_modules'), (er, i) => {