nyc
nyc copied to clipboard
nyc instrument fails when instrumenting file in-place
Link to bug demonstration repository
https://gitlab.com/eric.morand/nyc-instrument
Expected Behavior
nyc instrument
command should instrument the given input in-place.
Observed Behavior
EEXIST: file already exists, mkdir '[...]/index.js'
The issue lies in const outFile = path.resolve(output, relFile)
in index.js. Because output === relFile
you get a nonsense path of cwd/path/to/file.js/path/to/file.js
. You get similar nonsense if you specify an output location by file name, ex. output = different/path/to/file.js
=> different/path/to/file.js/different/path/to/file.js
(makedir will create a directory named file.js).
The solution is to have output be .
when instrumenting a single file in place, rather than use the flag. This should probably be better documented.