c8
c8 copied to clipboard
Docs question: how should I specify multiple exclusions on the commandline?
Suppose I'm calling c8 on the commandline:
npx c8 --all --exclude <something> npm run test
and I want to exclude multiple folders (e.g. upgrade, test). Based on the documentation
--exclude, -x a list of specific files and directories that
should be excluded from coverage (glob
patterns are supported)
[default: ["coverage/**","packages/*/test{,s}/**","**/*.d.ts","test{,s}/**","t
est{,-*}.{js,cjs,mjs,ts}","**/*{.,-}test.{js,cjs,mjs,ts}","**/__tests__/**","*
*/{ava,nyc}.config.{js,cjs,mjs}","**/jest.config.{js,cjs,mjs,ts}","**/{karma,r
ollup,webpack}.config.js","**/{babel.config,.eslintrc,.mocharc}.{js,cjs}"]]
I thought I had to pass this in as a Javascript array
npx c8 --all --exclude '["upgrade/**","test/**"]' npm run test
but this doesn't work. What works is passing multiple exclude flags:
npx c8 --all --exclude "upgrade/**" --exclude "test/**" npm run test
and it looks like I can also exclude folders by just passing the folder directly:
npx c8 --all --exclude "upgrade" --exclude "test" npm run test
Is the multiple flags method the intended way of passing exclusions, or is there a way to do it with only one flag?
Is the folder exclusion possibility intended and safe to write, or does it just work by accident? I thought it might be unintended because the default exclusion list includes constructs like "coverage/**" and "test{,s}/**" and it seems they could be simplified down to "coverage" and "test{,s}" if directory exclusion was supposed to work.