nspragg / filesniffer Goto Github PK
View Code? Open in Web Editor NEWFind files by matching content
Find files by matching content
I noticed that if you run some tests on Travis and specify some search criteria using FILE_HOUND, filesniffer doesn't emit any event, no error, no match and no end.
The same setup that does't work on CI, works locally when i run the tests.
The code is pretty simple:
const searchCriteria = FILE_HOUND.create()
.paths(projectRootPath)
.discard("build")
.depth(20)
.ignoreHiddenDirectories()
.ignoreHiddenFiles()
.ext('.java', '.kt');
const fileSniffer = FILE_SNIFFER.create(searchCriteria);
// match, end, error
If there anything else that i can do to debug and understand what is happening inside filesniffer?
I'm doing a search in files that contains the string target multiple times, and I'm returning the same file path multiple times, as many times as the target string appears.
Is this a bug or is this the expected behaviour? If is expected is there a way to return the file only once if the string appears at least one time?
I'm having an issue with the filesniffer, it only sniffs in the current document and in neither of the childrens, is there any way to specify that is should also check all children and all children of children?
The only fix I found is changing
https://github.com/nspragg/filesniffer/blob/master/src/filesniffer.js#L128
and adding 9999
instead of 0
No events are emitted when the input source (list of paths or Filehound results) are empty.
const sniffer = FileSniffer.create([]);
After the removal of fileniffer + file_hound, i can't anymore use the file hound discard()
feature. It would be good if we can create that in filesniffer..
Add support for including context (number of lines) before and after match:
const matches = await FileSniffer.create()
.path(filename)
.context(5) // 5 line before and after match
.collection(asArray())
.find('str');
Add a method .ignoreCase
to allow for a case insensitive search. This is useful for simple string searches e.g .find(str)
With the new api I can't use the FILE_HOUND criteria anymore and therefore can't use the
.ignoreHiddenDirectories()
.ignoreHiddenFiles()
Would be good to add them to filesniffer
API changes:
.path
and .paths
methods.create
with argsExample:
const FileSniffer = require('filesniffer');
const asArray = FileSniffer.asArray;
const lines = FileSniffer.create()
.paths(paths) // can be files and/or dirs
.collect(asArray()) // or just fn reference directly
.find(/mypattern/);
const {filename, line} = matchesAsArray[0];
// find files on the cwd containing pattern. Populate buffer.
FileSniffer.find(/pattern/, buffer);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.