From 4367ec45631a949ab43e2e9dc5668ae037ffc0d3 Mon Sep 17 00:00:00 2001 From: Andrew Finlay Date: Tue, 2 Apr 2019 15:50:42 +1100 Subject: [PATCH] [skip ci]Update instrument command description, and other relevant doc --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9103587c6..7018fa25b 100644 --- a/README.md +++ b/README.md @@ -197,14 +197,20 @@ nyc report --reporter= ## Producing instrumented source -nyc can produce a set of instrumented source files, suitable for client side deployment, by running: +The nyc `instrument` command can produce a set of instrumented source files, suitable for client side deployment in end to end testing. +You can create an instrumented version of your source code by running: ```bash nyc instrument [output] ``` -Where `input` can be any file or directory within the project root directory. -The `output` directory is optional and can be located anywhere, if it is not set the instrumented code with be sent to `stdout`. +`` can be any file or directory within the project root directory. +The `[output]` directory is optional and can be located anywhere, if it is not set the instrumented code will be sent to `stdout`. +For example, `nyc instrument . ./output` will copy all files from `.` to `./output` and produce instrumented versions of any source files it finds along the way. + +Run `nyc instrument --help` to display a list of available command options. + +**Note:** `nyc instrument` will not copy the contents of a `.git` folder to the output directory. ## Setting the project root directory @@ -231,7 +237,7 @@ By default, nyc only collects coverage for source files that are visited during It does this by watching for files that are `require()`'d during the test. Only source files that are visited during a test will appear in the coverage report and contribute to coverage statistics. -nyc will instrument all files if the `--all` flag is set. +nyc will instrument all files if the `--all` flag is set or if running `nyc instrument`. In this case all files will appear in the coverage report and contribute to coverage statistics. nyc will only collect coverage for files that are located under `cwd`, and then only `*.js` files or files with extensions listed in in the `extension` array. @@ -274,8 +280,8 @@ The `exclude` option has the following defaults settings: These settings exclude `test` and `__tests__` directories as well as `test.js`, `*.test.js`, and `test-*.js` files. Specifying your own exclude property completely replaces these defaults. -**Note:** The exclude list always implicitly contains `**/node_modules/**`, even if not explicitly specified in an overriding `exclude` array. -To reverse this you must add the negated exclude rule `!**/node_modules/`. +**Note:** We always add `**/node_modules/**` to the exclude list, even if not specified in the config. +You can override this by setting the `!**/node_modules/` negated exclude rule. For example, the following config will collect coverage for every file in the `src` directory regardless of whether it is `require()`'d in a test. It will also exclude any files with the extension `.spec.js`.