tvooo / sublime-grunt

Moved to https://github.com/sptndc/sublime-grunt
296 stars 35 forks source link

Rewrote a chunk of `list_gruntfiles()` - fixes #77 #94

Open rtpHarry opened 9 years ago

rtpHarry commented 9 years ago

This is the first piece of Python I've ever written today. After getting stumped by what path to set up and seeing others had been affected I ended up solving it I think.

The original list_gruntfiles() just asked for self.window.folders() which isn't a recursive list of the folders in the project. This code replaces the shallow search with a recursive folder search of each of those top level project folders, looking for the Gruntfile.(js|coffee).

Instead of using self.window.folders(), my code fires off a search of the file system using os.walk. I'm concerned that I might have done something bad as I know hitting the file system could be slow in large projects although I don't see any way around it. If any Python experts have a better idea please tweak it. I'm not sure if this information can be cached either?

From testing on Windows 8.1 it appears that its not case-sensitive either, so Gruntfile.js and gruntfile.js both worked for me.

rtpHarry commented 9 years ago

Another note, I'm running Sublime 2 v2.0.2, Build 2221 on Windows 8.1.

I haven't tested on any other versions / operating systems.