I have recently discovered ack and ack -ir --ignore-dir={node_modules,dist,.git} <search-term>
works great for most things but this
---node_modules/
---------------project1/
-----------------------node_modules/
---------------project2/
-----------------------node_modules/
I would like to search all files under the "root" node_modules and excluding all internal ones.
Note: if I run find . -type f | ack -v 'node_modules|.git|dist'
under the root node_modules folder, I get a proper file list. this happen because find .
gives out relative paths. Any way to feed this list to ack ?
ack -i <search-term> ./node_modules/*
should do what you want.
If you want to include hidden files and folders too, set shopt -s dotglob
(assumes Bash) first.
Background information:
ack
has many rules for ignoring files that you don't typically want to be searched built in.
As of at least version 2.14, this includes directories named .git
and node_modules
, at whatever level of the hierarchy (ack
searches recursively by default, though you may add -r
/ -R
/ --recursive
to make that explicit).
To see the complete list of directories / files that are ignored by default, run ack --dump
.
By using globbing (pathname expansion) to let the shell expand pattern ./node_modules/*
to a list of actual items inside ./node_modules
, the ignore rule for node_modules
is bypassed for those explicitly passed items.
node_modules
is in the default --ignore-dir
list in ack
for javascript.
You can disable this using the --noignore-dir
option to un-ignore node_modules.
directly on the command line:
% ack --noignore-dir=node_modules -i <search-term>
in your .ackrc
file:
# in .ackrc
--noignore-dir=node_modules
which affects all searches:
% ack -i <search-term>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With