Open eight04 opened 5 years ago
--exclude
parameter, or by setting an exclude
field in a .c8rc
.Sure. How can I help?
@eight04 we have similar functionality to this in the library nyc
, I think we would modify the logic here:
https://github.com/bcoe/c8/blob/master/lib/report.js#L164
To have similar logic to nyc
, in which it detects a path is outside the current working directory and excludes it.
After digging into the code, I think it is a test-exclude bug. test-exclude does exclude files outside of CWD, but it doesn't work if two paths have different drives: https://github.com/istanbuljs/istanbuljs/blob/c4e8b8e640acba43ecbe26ca3032a951de3ac3a6/packages/test-exclude/index.js#L96
const cwd = "D:\\dev\\project";
const filename = "C:\\Users\\Owner\\AppData\\Local\\Temp\\config.js";
path.relative(cwd, filename); // "C:\\Users\\...."
This also explains why this bug only occurs on Windows.
@eight04 would we be able to pull in a similar fix to the work done in istanbul do you think?
I think this will be fixed automatically when https://github.com/istanbuljs/istanbuljs/pull/422 is released.
I have some JavaScript configuration files that are dynamically generated during tests. It seems that those generated JS files are also counted as part of the source code. These config files are generated inside a temporary directory created by tmp, and they will be
require()
ed during the test.Here is a simple repro, run
npm test
to see the error. It seems that this problem is Windows-only. At least, Travis doesn't show this error:So: