Skip to content

Commit

Permalink
Replace lodash.flatten() with Array.flat() built-in
Browse files Browse the repository at this point in the history
Follow-up to pouchdb#8907
  • Loading branch information
alxndrsn committed Apr 12, 2024
1 parent 9afecb2 commit ecdee00
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bin/update-package-json-for-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var path = require('path');
var glob = require('glob');
var findRequires = require('find-requires');
var builtinModules = require('builtin-modules');
const { flatten, uniq } = require('lodash');
const { uniq } = require('lodash');

var topPkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
var modules = fs.readdirSync('./packages/node_modules');
Expand All @@ -24,14 +24,14 @@ modules.forEach(function (mod) {

// for the dependencies, find all require() calls
var srcFiles = glob.sync(path.join(pkgDir, 'lib/**/*.js'));
var uniqDeps = uniq(flatten(srcFiles.map(function (srcFile) {
var uniqDeps = uniq(srcFiles.map(function (srcFile) {
var code = fs.readFileSync(srcFile, 'utf8');
try {
return findRequires(code);
} catch (e) {
return []; // happens if this is an es6 module, parsing fails
}
}))).filter(function (dep) {
}).flat()).filter(function (dep) {
// some modules require() themselves, e.g. for plugins
return dep !== pkg.name &&
// exclude built-ins like 'inherits', 'fs', etc.
Expand Down

0 comments on commit ecdee00

Please sign in to comment.