dependency-tree 10.0.0 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/config.js +48 -0
  2. package/package.json +2 -1
package/lib/config.js ADDED
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ const path = require('node:path');
4
+ const process = require('node:process');
5
+ const { debuglog } = require('node:util');
6
+
7
+ const debug = debuglog('tree');
8
+
9
+ module.exports = class Config {
10
+ constructor(options = {}) {
11
+ this.filename = options.filename;
12
+ this.directory = options.directory || options.root;
13
+ this.visited = options.visited || {};
14
+ this.nonExistent = options.nonExistent || [];
15
+ this.isListForm = options.isListForm;
16
+ this.requireConfig = options.config || options.requireConfig;
17
+ this.webpackConfig = options.webpackConfig;
18
+ this.nodeModulesConfig = options.nodeModulesConfig;
19
+ this.detectiveConfig = options.detective || options.detectiveConfig || {};
20
+ this.tsConfig = options.tsConfig;
21
+ this.noTypeDefinitions = options.noTypeDefinitions;
22
+
23
+ this.filter = options.filter;
24
+
25
+ if (!this.filename) throw new Error('filename not given');
26
+ if (!this.directory) throw new Error('directory not given');
27
+ if (this.filter && typeof this.filter !== 'function') throw new Error('filter must be a function');
28
+
29
+ if (typeof this.tsConfig === 'string') {
30
+ debug('preparsing the ts config into an object for performance');
31
+ const ts = require('typescript');
32
+ const tsParsedConfig = ts.readJsonConfigFile(this.tsConfig, ts.sys.readFile);
33
+ const obj = ts.parseJsonSourceFileConfigFileContent(tsParsedConfig, ts.sys, path.dirname(this.tsConfig));
34
+ this.tsConfig = obj.raw;
35
+ }
36
+
37
+ debug(`given filename: ${this.filename}`);
38
+
39
+ this.filename = path.resolve(process.cwd(), this.filename);
40
+
41
+ debug(`resolved filename: ${this.filename}`);
42
+ debug('visited: ', this.visited);
43
+ }
44
+
45
+ clone() {
46
+ return new Config(this);
47
+ }
48
+ };
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "dependency-tree",
3
- "version": "10.0.0",
3
+ "version": "10.0.1",
4
4
  "description": "Get the dependency tree of a module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "files": [
8
8
  "bin/cli.js",
9
+ "lib/*.js",
9
10
  "index.js"
10
11
  ],
11
12
  "bin": {