Skip to content

Commit

Permalink
feat: add a check for a default number of dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
helio-frota committed Nov 29, 2021
1 parent 18e425d commit 05f353c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/plugins/resolved.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
const Arborist = require('@npmcli/arborist');
const { createError } = require('../lib/result');
const { createError, createWarning } = require('../lib/result');
const isGitURL = require('is-git-url');

const NUM_OF_DEPS = 20;

const resolvedPlugin = async (pkg, config, options, path = './npcheck-env') => {
const results = [];
const arborist = new Arborist({ path: path });
const result = await arborist.loadActual();
const children = result.children;
if (children.size - 1 > NUM_OF_DEPS) { // minus 1, the module itself
results.push(
createWarning(
`The module "${pkg.name}" has more dependencies (including sub-dependencies) than the default "${NUM_OF_DEPS}".`
)
);
}
children.forEach(c => {
const resolved = c.resolved.toString();
if (isGitURL(resolved)) {
Expand Down

0 comments on commit 05f353c

Please sign in to comment.