You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 13, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: cli.js
+3-3
Original file line number
Diff line number
Diff line change
@@ -31,16 +31,16 @@ if (args.version) {
31
31
}
32
32
33
33
if(args.help||args._.length===0){
34
-
console.log('\nUsage: dependency-check <path to package.json or module folder> <additional entries to add> <options>')
34
+
console.log('\nUsage: dependency-check <path to module files, package.json or module folder> <additional entries to add> <options>')
35
35
36
36
console.log('\nOptions:')
37
37
console.log('--missing (default) Check to make sure that all modules in your code are listed in your package.json')
38
38
console.log('--unused, --extra The inverse of the --missing check and will tell you which modules in your package.json *were not* used in your code')
39
39
console.log("--no-dev Won't tell you about devDependencies that are missing or unused")
40
40
console.log("--no-peer Won't tell you about peerDependencies that are missing or unused")
41
41
console.log("--ignore-module, -i Won't tell you about these module names when missing or unused. Supports globbing")
42
-
console.log('--entry By default your main and bin entries from package.json will be parsed, but you can add more the list of entries by passing them in as --entry')
43
-
console.log("--no-default-entries Won't parse your main and bin entries from package.json")
42
+
console.log('--entry If a package.json or module folder was set, then by default the main and bin entries in the package.json will be parsed, but you can add more the list of entries by passing them in as --entry. Supports globbing')
43
+
console.log("--no-default-entries Won't parse your main and bin entries from package.json even when a package.json or module folder has been defined")
44
44
console.log('--detective Requireable path containing an alternative implementation of the detective module that supports alternate syntaxes')
45
45
console.log("--extensions, -e List of file extensions with detective to use when resolving require paths. Eg. 'js,jsx:detective-es6'")
Copy file name to clipboardExpand all lines: readme.md
+17-6
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ dependency-check `2.x` supports Node.js 0.10 and later (Dev note: published usin
17
17
18
18
## how it works
19
19
20
-
`dependency-check` parses your module code starting from the default entry files (e.g. `index.js` or `main` and any `bin` commands defined in package.json) and traverses through all relatively required JS files, ultimately producing a list of non-relative modules
20
+
`dependency-check` parses your module code starting from the default entry files (e.g. `index.js` or `main` and any `bin` commands defined in package.json or if specific files has been defined, then those) and traverses through all relatively required JS files, ultimately producing a list of non-relative modules
21
21
22
22
***relative** - e.g. `require('./a-relative-file.js')`, if one of these are encountered the required file will be recursively parsed by the `dependency-check` algorithm
23
23
***non-relative** - e.g. `require('a-module')`, if one of these are encountered it will get added to the list of dependencies, but subdependencies of the module will not get recursively parsed
@@ -28,14 +28,24 @@ the goal of this module is to simply check that all non-relative modules that ge
28
28
29
29
```
30
30
$ npm install dependency-check -g
31
-
$ dependency-check <package.json file or module folder path>
31
+
$ dependency-check <path to module file(s), package.json or module folder>
32
32
33
33
# e.g.
34
34
35
35
$ dependency-check ./package.json
36
36
Success! All dependencies used in the code are listed in package.json
37
37
$ dependency-check ./package.json --unused
38
38
Success! All dependencies in package.json are used in the code
39
+
40
+
# or with file input instead:
41
+
42
+
$ dependency-check ./index.js
43
+
Success! All dependencies used in the code are listed in package.json
44
+
45
+
# even with globs and multiple inputs:
46
+
47
+
$ dependency-check ./test/**/*.js ./lib/*.js
48
+
Success! All dependencies used in the code are listed in package.json
39
49
```
40
50
41
51
`dependency-check` exits with code 1 if there are discrepancies, in addition to printing them out
@@ -64,23 +74,23 @@ ignores a module. This works for both `--unused` and `--missing`. You can specif
64
74
65
75
### --entry
66
76
67
-
by default your `main` and `bin` entries from package.json will be parsed, but you can add more the list of entries by passing them in as `--entry`, e.g.:
77
+
adds more files to be checked to any of the default ones already added, like `tests.js` to the default ones resolved from package.json:
68
78
69
79
```
70
80
dependency-check package.json --entry tests.js
71
81
```
72
82
73
-
in the above example `tests.js` will get added to the entries that get parsed + checked in addition to the defaults. You can specify as many separate `--entry` arguments as you want
83
+
you can specify as many separate `--entry` arguments as you want. `--entry` also supports globbing like `**/*.js` and similar.
74
84
75
-
you can also instead add additional entries directly after your package definition, like:
85
+
you can also instead add additional entries directly after your main path, like:
76
86
77
87
```
78
88
dependency-check package.json tests.js
79
89
```
80
90
81
91
### --no-default-entries
82
92
83
-
running `dependency-check package.json --no-default-entries --entry tests.js` won't parse any entries other than `tests.js`. None of the entries from your package.json `main` and `bin`will be parsed
93
+
running eg. `dependency-check package.json --no-default-entries --entry tests.js` won't add any default entries despite the main path given being one to a package.json or module folder. So only the `tests.js` file will be checked
84
94
85
95
### --extensions, -e
86
96
@@ -126,3 +136,4 @@ See [grunt-dependency-check](https://github.com/sindresorhus/grunt-dependency-ch
126
136
127
137
-[detective](https://www.npmjs.org/package/detective) is used for parsing `require()` statements, which means it only does **static requires**. this means you should convert things like `var foo = "bar"; require(foo)` to be static, e.g. `require("bar")`
128
138
- you can specify as many entry points as you like with multiple `--entry foo.js` arguments
139
+
- use globbing to effectively add all the files you want to check
0 commit comments