nyc icon indicating copy to clipboard operation
nyc copied to clipboard

nyc instrument fails when instrumenting file in-place

Open ericmorand opened this issue 3 years ago • 1 comments

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'

ericmorand avatar Aug 04 '21 09:08 ericmorand

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.

henry-filosa avatar Oct 19 '21 17:10 henry-filosa