kokarn / atom-grunt-runner

Run Grunt tasks from Atom.
MIT License
31 stars 23 forks source link

Support Multiple Grunt Files #94

Open wunderdojo opened 7 years ago

wunderdojo commented 7 years ago

First off, thanks for writing this, it's a huge help.

I'm wondering if it's possible to add support for multiple grunt files. I often have several projects open each of which has their own grunt tasks defined. In NetBeans I can simply right click on the gruntfile in any project to view and run any of the tasks. With this addon the first gruntfile encountered gets loaded so if I didn't close all of the files from another project, then when I launch Atom I'm restricted to that project's grunt tasks.

I can open each project in a new editor but that gets pretty cumbersome. Being able to do something what you can in NetBeans would be amazing.

kokarn commented 7 years ago

Interesting approach. I've never actually done like that. I quite like the idea of having a single project view for each project and switching between them.

With that said, I don't see why this would be impossible to implement.

We'd have to traverse up from every file you open and somehow build a list that you could choose from and present that. Probably somewhere around here https://github.com/kokarn/atom-grunt-runner/blob/master/lib/grunt-runner-view.coffee#L79-L81

I don't think I will start work on this anytime soon but a PR is always welcome :)

wunderdojo commented 7 years ago

Thanks for the quick reply. This is what it looks like in NetBeans. I'll see if I can do anything with it. netbeans-grunt

kokarn commented 7 years ago

So you open each projects root folder at the same time in Atom? I was thinking you only opened a few files from each project.

wunderdojo commented 7 years ago

I'm primarily working on a bunch of WordPress plugins. Each one has its own Git repo and a I vagrant tasks that automate the entire release process including uploading the new version to our server; updating the version numbers so that customers get the update notice; etc. In NetBeans I simply have the entire local WP install loaded as a project and then I can hop from plugin to plugin running tasks as needed by clicking on the Gruntfile in that particular plugin. In the screenshot above, if I opened a different folder on the left and clicked on that folder's Gruntfile you would see a different set of available tasks, no need to reload anything.

kokarn commented 7 years ago

Ah, I see. That's quite a bit different from how I work most of the time.

Should work fine tho, just re-triggering the lookup for a Gruntfile from the selected file and upwards should result in you getting the closest one to that file.

wunderdojo commented 7 years ago

Great, thanks. I'll give it a go this week and see what I can come up with. Really appreciate the help.

tenKinetic commented 7 years ago

I've implemented this in my own fork. Needs a little more work before a pull request could be made though.

I came across this issue because I lost this functionality when I updated today after quite a while. Turns out my previously committed pull request was reverted.

The version I've done this time is a bit different though. Before it was purely to allow switching grunt files when opening a file from a different project folder (and the grunt file was always a the root of the project). This time a project can contain multiple grunt files and the closest one up the hierarchy from the file in question is used.

I've still got to remove some redundant code from the previous version, review my stream of consciousness coding and go about my business for a while to make sure there's no cracks.

Feel free to take lib/grunt-runner-view.coffee from my fork (in the multiple-grunt-files branch) if you want this functionality in the mean time.

kokarn commented 7 years ago

Wow, that's great news man!

Not sure at all why it was reverted, maybe in the shuffle when I got ownership or something.

Looking forward to the update!

wunderdojo commented 7 years ago

That's awesome, thanks so much for sharing it.