nicosantangelo / sublime-gulp

Run Gulp tasks and use snippets from Sublime Text
https://sublime-gulp.nicosantangelo.com/
MIT License
155 stars 18 forks source link

proccess keeps running when sublime text exists [windows] #26

Closed dirad closed 9 years ago

dirad commented 9 years ago

Running a Gulp task with watch must be killed specifically before exiting. In case of closing sublime text without exisiting, node.exe keeps running - and a new sublime text session will not be able to pick up the process and will error if running a new gulp task!

nicosantangelo commented 9 years ago

I'm not sure if Sublime provides a callback for when the editor closes, I'll definitely take a look and report back here.

dirad commented 9 years ago

sweet!

nicosantangelo commented 9 years ago

Sadly there's no callback when Sublime exits, so what I did is creating a new command (gulp_exit) which will kill all running tasks and then close the editor. There's however a callback when a view closes but to use it I should check on every view close if it's the last one of all the open windows, which is not very nice.

The command works, but the annoying part is that you'll have to bind it to a shortcut by hand, like this:

    // Mac
    { "keys": ["super+q"], "command": "gulp_exit" },

    // Linux/Windows
    { "keys": ["alt+f4"], "command": "gulp_exit" }

The command is in this branch if you want to try it out. I'll merge it into master once I'll update the docs.

Let me know if this helps or if you have a better idea!

dirad commented 9 years ago

nice workaround, but generally i wouldn't want to override a native OS shortcut.. Plus it wont fire if someone press the close [X] button, or File->exit ..

Also - i am new to git, and i dont actually know how to get the branch for the plugin... [package control would usually do that for me] Can you help me in getting the new code?

Moreover - are you sure gulp_exit closes the editor in the same manner that it closes itself?

thanks

nicosantangelo commented 9 years ago

nice workaround, but generally i wouldn't want to override a native OS shortcut.. Plus it wont fire if someone press the close [X] button, or File->exit ..

I know, it's not really the best experience :(, it's a shame Sublime doesn't provide a callback for this. I'll give the 'view close' callback a try and if it works maybe make it available with a flag explaining that it could impact performance.

Also - i am new to git, and i dont actually know how to get the branch for the plugin... [package control would usually do that for me] Can you help me in getting the new code?

Yup! It might be a bit annoying, but you'll have to do something like this:

  1. Remove gulp using Package Controls Remove Package command.
  2. Go to your packages folder ([Ctrl/Cmd]+Shift+P -> Browse Packages).
  3. Open a terminal.
  4. Clone this project there: $> git clone git@github.com:NicoSantangelo/sublime-gulp.git Gulp.
  5. cd into the package and checkout the branch:
$> cd Gulp
$> git checkout clean-exit

That's it! (maybe restart Sublime)

When you want to go back to using PackageControl, you can safely remove the Gulp folder and re-install using PackageControls Install Package inside Sublime. I'll try to get this on master as fast as I can, but if you want to test it is really helpful. Sorry if it's too much of a hassle

Moreover - are you sure gulp_exit closes the editor in the same manner that it closes itself?

Yes!, Sublime internally calls exit to close itself on the default Key Bindings.

nicosantangelo commented 9 years ago

Hey!

I did some experiments trying to figure out when the user is closing the editor without using a Key Binding and sadly there's no straightforward way that works 100% of the time.

I think I'll merge this with master so at least we have the Key Binding, and you can test it without having to clone the branch.

nicosantangelo commented 9 years ago

Well, this is in. I know it's not the best solution, but currently it's the only thing that (kind of) works.

I'll close this, but if you have any problem or suggestion, let me know and I'll reopen (please tag me so Github sends me a notification).

Thanks again!

dirad commented 9 years ago

ok thank you sir.