Skip to content

Commit

Permalink
fix: Respect 'direct' option correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
RSeidelsohn committed Feb 2, 2022
1 parent b4f1785 commit 5b8c7e5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ const flatten = function flatten(options) {
/*istanbul ignore else*/
if (json.dependencies) {
Object.keys(json.dependencies).forEach((name) => {
const childDependency = json.dependencies[name];
const childDependency = options.depth > options._args.direct ? {} : json.dependencies[name];
const dependencyId = `${childDependency.name}@${childDependency.version}`;

if (data[dependencyId]) {
Expand All @@ -258,6 +258,7 @@ const flatten = function flatten(options) {
development: options.development,
production: options.production,
unknown,
depth: options.depth + 1,
});
});
}
Expand Down Expand Up @@ -369,7 +370,9 @@ exports.init = function init(args, callback) {
development: args.development,
production: args.production,
unknown: args.unknown,
depth: 0,
});

const colorize = args.color;
const sorted = {};
let filtered = {};
Expand Down

0 comments on commit 5b8c7e5

Please sign in to comment.