What's wrong with atom.project.scan (or me)?


#1

I’m working on a custom package and I’m unable to get any sensible results from the atom.project.scan method. I can supply anything in the regex parameter, and it always returns every single .js file in the opened project (folder). How come it does not return other files, such as .json and .html files?

What I’m looking for, is a way to find the “manifest.json” within the opened project, but with the atom.project.scan this doesn’t seem to be easy, I’m probably doing it wrong. Does .scan run a files can within the files, or simply look into the file names?


#2

The scan method test the regex against the files content, this is how the find-and-replace package looks for matches. If you want to grep on the files name instead you should probably take a look at the fuzzy-finder package, more precisely the following parts :

https://github.com/atom/fuzzy-finder/blob/master/lib/main.coffee#L13-L16

https://github.com/atom/fuzzy-finder/blob/master/lib/path-loader.coffee

It initializes a task that will asynchronously fetch all the paths in the project (minus the ignored files) and affect it in @projectPaths when done.


#3

Thanks, I got it working now :slight_smile: Had to include the load-paths-handler as well, and I made some modifications to it. It appears all I really need is fs-plus, but this respects ignored files which is nice.