Skip to content
This repository was archived by the owner on Feb 15, 2022. It is now read-only.
This repository was archived by the owner on Feb 15, 2022. It is now read-only.

Depth not working? #47

@flopes89

Description

@flopes89

Not sure why, but to me it seems like the depth option isn't working at all:

$ npm init
$ npm i -D read-installed
$ npm i react
// index.js

const readInstalled = require("read-installed");

let depth = 0;

const log = (pkg) => {
	console.log("-".repeat(depth) + " " + pkg.name + "@" + pkg.version);
	depth += 1;
	Object.keys(pkg.dependencies).forEach((name) => {
		log(pkg.dependencies[name]);
	});
	depth -= 1;
};

readInstalled(".", { depth: 0 }, (err, data) => log(data));

Yields the following result:

$ node index.js
 root@1.0.0
- react@16.8.4
-- loose-envify@1.4.0
--- js-tokens@4.0.0
-- object-assign@4.1.1
-- prop-types@15.7.2
--- loose-envify@1.4.0
---- js-tokens@4.0.0
--- object-assign@4.1.1
--- react-is@16.8.4
-- scheduler@0.13.4
--- loose-envify@1.4.0
---- js-tokens@4.0.0
// ... etc

Instead of what I would expect:

$ node index.js
 root@1.0.0
- react@16.8.4

Without and transient dependencies ... ?

  • node 8.9.0, npm 5.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions