-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
Don't instrument files outside of the current working directory #160
Conversation
The test is superfluous as the presence of node_modules in the filename causes it to be excluded. There are also repeat assertions for the same values.
Clarify what's being tested. Remove misleading comment. Explicitly test for exclude overriding include.
@novemberborn great work; I'll do a thorough test on a few platforms/projects and we can release this to a |
Great! |
@novemberborn starting doing a little bit of testing, this patch doesn't seem to be working for a linked module: One other thing we might want to be mindful of is this logic: relFile = relFile.replace(/^\.\//, '') // remove leading './'. We should probably be using |
@novemberborn the good news, is I saw that this patch solves the issues @micnic was having \o/ |
Or just account for either slash in the regexp str.replace(/\.[\\\/]/, '') Using |
👍 |
Files outside of the current working directory (meaning higher up in the file hierarchy) should not be instrumented. Fixes istanbuljs#157 where nyc is run from inside a node_modules directory. Fixes istanbuljs#154 where 'npm link' is used to fulfill dependencies. This removes matching the include/exclude patterns to the absolute filename, the patterns are now applied only to the relative portion within the current working directory. addAllFiles() has been changed to explicitly add files in the current working directory only.
There is no specific test for this, I've simply repeated the assertions that started with './'.
c685e13
to
9dd150e
Compare
Ha, this is a nice one! I reproduced this by cloning https://github.com/bcoe/yargs/tree/split-out-parser and https://github.com/yargs/yargs-parser/tree/require.main.filename into sibling directories, then Turns out when you have paths like these:
Pushed a commit which fixes that, using @jamestalmage's method. |
lol @novemberborn that's great, as usual I manage to be a nightmare user of our own library and find a crazy edge-case: |
Don't instrument files outside of the current working directory
Files outside of the current working directory (meaning higher up in the file hierarchy) should not be instrumented.
Fixes #157 where nyc is run from inside a
node_modules
directory.Fixes #154 where 'npm link' is used to fulfil dependencies.
This removes matching the include/exclude patterns to the absolute filename, the patterns are now applied only to the relative portion within the current working directory.
addAllFiles()
has been changed to explicitly add files in the current working directory only.Some other tests related to include/exclude behavior have been cleaned up.
Note that I'm not entirely certain
filename
inshouldInstrumentFile()
is always absolute. Review on that front would be especially appreciated.This changes the include/exclude matching behavior, but restricting it to the cwd makes more sense to me.