Add support for --cwd (#542) - #620
Conversation
|
Changes Unknown when pulling 28d8df7 on Speedy37:master into ** on istanbuljs:master**. |
|
@Speedy37 rather than adding a new |
|
NYC_CWD isn't the same as nyc working directory. edit: I'm wrong, NYC_CWD is like the cwd, it's just I had the next piped command in the wrong working directory. |
|
I updated this PR to use cwd naming. But I'm not convinced this is exactly what you want, because cwd doesn't only impact file lookup, it also impact cache location. |
|
Changes Unknown when pulling 3b5b8a8 on Speedy37:master into ** on istanbuljs:master**. |
|
@Speedy37 maybe I'm just not fully understanding the problem you're looking to solve. Do you have a repo that benefits from manually setting the root directory, is the problem not addressed by Just want to make sure we're solving a specific issue you're running into before we land anything. |
|
@Speedy37 this did the trick for you, for your use-case? will work on landing this soon, have just been pretty swamped triaging old issues (trying to cleanup the project a bit). |
|
Sry for the delay, I was on vacations. The initial problem was to be able to run nyc by including files at /mypath/node_modules/mymodule/*.js while beeing able to reject /mypath/node_modules/mymodule/node_modules/**. I was able to do this only by using the cwd trick because the 'node_modules/' exclusion is deeply included by nyc. ('!node_modules/' doesn't help because it prevents me to reject /mypath/node_modules/mymodule/node_modules/**). The other problem being NYC_CWD modified by nyc by looking upwards for package.json, making it unreliable (I'm building my npm packages outside the source folder). So being able to set --cwd would make the whole process much more reliable. NYC_CWD has two main effect:
In my opinion, two arguments (--root and --tmpdir) would be better than --cwd and their explanations would be more specific. |
|
@Speedy37 as long as the default behavior is reasonable, I'd be comfortable with splitting configuration into two parts I've been swamped with life/work stuff lately, and getting a bit buried in OSS work. would love to have you join the community slack I recently stood up: http://devtoolscommunity.herokuapp.com/ it's a great way to kick me in the butt and make sure we get work over the finish line. |
|
After reviewing the whole list of arguments, you already define temp-directory and because you name cwd the base path for file lookup, I think --cwd is the best name (it won't be confusing with code implementation naming). |
|
@Speedy37 this is now released in |
|
Working like a charm |
|
This does not seem to work. I can run my tests, but the coverage report is broken. |
|
@Speedy37 have you had a chance to dig into this at all, I would like to make sure that if we add this feature it's working as expected. @PowerSupply are you specifically having trouble with the |
|
I've reverted my builds to version v11.1.0 due to #668, but from my tests the --cwd flag is working fine and with it I didn't had to clean old coverage reports (there is a check that disable cleaning .nyc_output if NYC_CWD is defined). |
|
@bcoe yes and no. My problem is that I want to use the --all flag to include "files that have not been required in your tests" (as per the documentation). But if I set the --all flag then all files in my project gets included although I have specified include to only include files in a certain folder. Running the command from a subfolder does not seem to stifle the reach of --all, it still includes all files from my project root (where node_modules is). The previous solution for this was to use the --root flag but it is no longer an option. Therefore I tried to use --cwd (that is still undocumented in the readme) instead but it does not work. The combination of --cwd and --all does not work like --root and --all used to. Right now I can see no other solution to cover all files in my "source" folder than to use the --all flag and then having to manually exclude all folders/files in my project that are not under the sources directory. |
|
@PowerSupply without --cwd nyc will select cwd as the first folder in the path that is node_modules, if none then cwd is the current working directory. --cwd and --all should work like --root and --all used to (I got it working without troubles) What is the current behavior when you use --cwd ? If you have no instrumented file at all, see #668 |
|
Ok, so my problem was somehow related to using babel-plugin-istanbul in a way that I dont understand. I do not have time to look into the error right now but may investigate the problem later. Thanks for your support! |
I added support for --root option
I found out that the
cwdoption does exactly what the --root is supposed to do except:So I added a --root option that simply force cwd to be what I tell it to be.