Skip to content

Commit afd9cc8

Browse files
committed
fixup: add docs
1 parent aef8179 commit afd9cc8

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

docs/lib/content/commands/npm-query.md

+22-9
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,32 @@ npm query ":type(git)" | jq 'map(.name)' | xargs -I {} npm why {}
133133
},
134134
...
135135
```
136-
### Package lock only mode
137136

138-
If package-lock-only is enabled, only the information in the package
139-
lock (or shrinkwrap) is loaded. This means that information from the
140-
package.json files of your dependencies will not be included in the
141-
result set (e.g. description, homepage, engines).
137+
### Expecting a certain number of results
138+
139+
One common use of `npm query` is to make sure there is only one version of
140+
a certain dependency in your tree. This is especially common for
141+
ecosystems like that rely on `typescript` where having state split
142+
across two different but identically-named packages causes bugs. You
143+
can use the `--expect-results` or `--expect-result-count` in your setup
144+
to ensure that npm will exit with an exit code if your tree doesn't look
145+
like you want it to.
146+
147+
148+
```sh
149+
$ npm query '#react' --expect-result-count=1
150+
```
151+
152+
Perhaps you want to quickly check if there are any production
153+
dependencies that could be updated:
154+
155+
```sh
156+
$ npm query ':root>:outdated(in-range).prod' --no-expect-results
157+
```
142158

143159
### Package lock only mode
144160

145-
If package-lock-only is enabled, only the information in the package
146-
lock (or shrinkwrap) is loaded. This means that information from the
147-
package.json files of your dependencies will not be included in the
148-
result set (e.g. description, homepage, engines).
161+
If package-lock-only is enabled, only the information in the package lock (or shrinkwrap) is loaded. This means that information from the package.json files of your dependencies will not be included in the result set (e.g. description, homepage, engines).
149162

150163
### Configuration
151164

0 commit comments

Comments
 (0)