kokarn / atom-grunt-runner

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

Run specific Grunt task without clicking? #78

Open iabw opened 8 years ago

iabw commented 8 years ago

Hi, I'm new to Atom and was playing with Atom Toolbar, and I wanted a button that ran a specific Grunt task. It expects its tasks to be strings, but there's no way to run a specific task from grunt-runner's defined atom commands.

What I ended up doing was adding my own command in grunt-runner.coffee that looks like

atom.commands.add 'atom-workspace', 'grunt-runner:js', () =>
    startProcess = @view.startProcess.bind @view
    startProcess 'js'

This is working, but it's pretty gross, doesn't allow me to add new buttons for tasks without editing grunt-runner, and I'm not sure if my changes would be automatically over-written when grunt-runner updates (will they?)

What I want is to be able to define a task in toolbar like "grunt-runner:{task-name}" and have grunt-runner "just work". However, from digging into it and thinking about it a bit, it looks like that might actually require changes to Atom's command registry to allow extra arguments or something. Packages are easy, but I'm not very clear on how to hack something as core as the command registry (I also find Coffeescript pretty difficult to read).

Any thoughts or advice?

kokarn commented 8 years ago

I'd say even looking at copying the whole package and rolling your own. @nickclaw has been MIA since July so any pull-requests might have to wait until they are published on apm.

iabw commented 8 years ago

Thanks for the fast response. Any tips on making something like this work?

// Register
atom.commands.add 'atom-workspace', 'grunt-runner', (task) =>
    startProcess = @view.startProcess.bind @view
    startProcess task

// Run
atom.commands.dispatch( 'atom-workspace', 'grunt-runner:js' )

Am I basically right that this would require modifying atom core? Basically, I want something like Backbone's events where you can bind to the "root" event. Backbone does this by firing separate events.

I imagine there's not a magic way to make Atom play nice with a pattern like this? Currently it only matches explicit commandNames against its registry, and doesn't fire events for the root events the way Backbone does?

smnbbrv commented 8 years ago

@kokarn yes, absolutely agree about copying the package... It really should be maintained by somebody

kokarn commented 8 years ago

So, i've taken over as the maintainer for now.

Any pull-request is greatly appreciated :)