This command finds all package.json files that declare a dependency on chalk:
rg -F '"chalk":' -g package.json --files-with-matches
This command finds all private packages:
rg -F '"private": true' -g package.json --files-without-match
If there a way to write a rg command that combines both? I.e., "list files that contain "chalk": but don't contain "private": true". Thanks.
Not with a single call to rg, but you can do it by combining it with other shell commands. This will give you the intersection between the two result sets:
{
rg -F '"chalk":' -g package.json --files-with-matches &
rg -F '"private": true' -g package.json --files-without-match
} | awk 'seen[$0]++ == 1' # or `sort | uniq -d` if you don't mind waiting for output
Thanks, I'll probably go that route. Wanted to ask first as doing it in one command would make it 2x faster.
@okdana I love that awk trick.
@borekb If this were to be fixed, it would be fixed by #875, if I decide to do it. Still unsure. So I'm going to close this as a duplicate.
Most helpful comment
Not with a single call to
rg, but you can do it by combining it with other shell commands. This will give you the intersection between the two result sets: