Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add .cjs, .mjs, .ts, .tsx, .jsx to default extensions #1110

Merged
merged 1 commit into from
May 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ This table is a quick TLDR for the rest of this readme and there are more advanc
| ----------- | ----------- | ---- | ------- |
| `all` | Whether or not to instrument all files (not just the ones touched by your test suite) | `Boolean` | `false` |
| `check-coverage` | Check whether coverage is within thresholds, fail if not | `Boolean` | `false` |
| `extension` | List of extensions that nyc should attempt to handle in addition to `.js` | `Array<String>` | `['.js']` |
| `extension` | List of extensions that nyc should attempt to handle in addition to `.js` | `Array<String>` | `['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx']` |
| `include` | See [selecting files for coverage] for more info | `Array<String>` | `['**']`|
| `exclude` | See [selecting files for coverage] for more info | `Array<String>` | [list](https://github.com/istanbuljs/istanbuljs/blob/master/packages/test-exclude/default-exclude.js) |
| `reporter` | [Coverage reporters to use](https://istanbul.js.org/docs/advanced/alternative-reporters/) | `Array<String>` | `['text']` |
Expand Down Expand Up @@ -148,7 +148,7 @@ Only source files that are visited during a test will appear in the coverage rep
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 the `extension` array.
nyc will only collect coverage for files that are located under `cwd`, and then only files with extensions listed in the `extension` array.

You can reduce the set of instrumented files by adding `include` and `exclude` filter arrays to your config.
These allow you to shape the set of instrumented files by specifying glob patterns that can filter files from the default instrumented set.
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports.builder = function (yargs) {
})
.option('extension', {
alias: 'e',
default: [],
default: ['.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
describe: 'a list of extensions that nyc should handle in addition to .js'
})
.option('source-map', {
Expand Down
6 changes: 6 additions & 0 deletions lib/commands/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ exports.builder = function (yargs) {
describe: 'a list of specific files that should be covered, glob patterns are supported',
global: false
})
.option('extension', {
alias: 'e',
default: ['.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
describe: 'a list of extensions that nyc should handle in addition to .js',
global: false
})
.option('show-process-tree', {
describe: 'display the tree of spawned processes',
default: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/config-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Config.buildYargs = function (cwd) {
})
.option('extension', {
alias: 'e',
default: [],
default: ['.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
describe: 'a list of extensions that nyc should handle in addition to .js',
global: false
})
Expand Down