Skip to content

Commit 1f6c3d4

Browse files
AndrewFinlaycoreyfarrell
authored andcommitted
docs: project root directory and --cwd doc (#1032)
1 parent 051d95a commit 1f6c3d4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,24 @@ Install custom reporters as a development dependency and you can use the `--repo
195195
nyc report --reporter=<custom-reporter-name>
196196
```
197197

198+
## Setting the project root directory
199+
200+
nyc runs a lot of file system operations relative to the project root directory.
201+
During startup nyc will look for the *default* project root directory.
202+
The *default* project root directory is the first directory found that contains a `package.json` file when searching from the current working directory up.
203+
If nyc fails to find a directory containing a `package.json` file, it will use current working directory.
204+
You can change the project root directory with the `--cwd` option.
205+
206+
nyc uses the project root directory when:
207+
* looking for source files to cover
208+
* creating globs for include and exclude rules during file selection
209+
* loading custom require hooks from the `require` array
210+
211+
nyc may create artefact directories within the project root, such as:
212+
* the report directory, `<project-root>/coverage`
213+
* the cache directory, `<project-root>/node_modules/.cache/nyc`
214+
* the temp directory, `<project-root>/.nyc_output`
215+
198216
## Selecting files for coverage
199217

200218
By default, nyc only collects coverage for source files that are visited during a test.
@@ -217,7 +235,6 @@ We use the following process to remove files from consideration:
217235
2. Remove any files that are found in the `exclude` array.
218236
3. Restore any exclude negated files that have been excluded in the second step.
219237

220-
221238
### Using include and exclude arrays
222239

223240
If there are paths specified in the `include` array, then the set of covered files will be limited to eligible files found in those paths.

0 commit comments

Comments
 (0)