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

[Feature Request] Delete .sublime-gulp.cache when process is killed #87

Closed adamdehaven closed 7 years ago

adamdehaven commented 7 years ago

I see that there's a shortcut command for deleting the .sublime-gulp.cache file:

Gulp: Delete Cache

Is there a way to automatically delete the .sublime-gulp.cache file when the gulp task is killed?

For example, after running Gulp: Kill running tasks, delete the .sublime-gulp.cache file by default? I could see this being implemented as another User setting; something like:

{
    "delete_cache_on_task_kill": true
}
nicosantangelo commented 7 years ago

Hey!

While I think this might be a good idea, I'm a bit reluctant to add more settings to the package if it's a feature you can get any other way. How about this, you can create a custom command to do the job easily.

1) Create a .py file in your ...Sublime Text 3/Packages/User folder (you can get there by running the command Preferences: Browse Packages.The name of the file is not important

2) Add the following command to it:

custom_gulp_command.py

class GulpDeleteCacheOnKill(sublime_plugin.WindowCommand):
    def run(self):
        self.window.run_command("gulp_kill")
        self.window.run_command("gulp_delete_cache")

3) To add the command to the command pallete, you need to create a .sublime-commands on the same folder

4) Add the command to it:

custom_gulp_command.sublime-commands

[
  {
    "caption": "Gulp: Clean",
    "command": "gulp_delete_cache_on_kill"
  }
]

the name of the command is the underscore version of the class name we wrote earlier.

That's it! if all went well you can now choose Gulp: Clean from your command pallete. I know it's a bit of work on your part but I think it's not that bad

Let me know!

adamdehaven commented 7 years ago

This looks like a great solution. I'll try it out shortly -- thanks!

adamdehaven commented 7 years ago

Looks like everything worked. Here are the completed files in case anyone else would like to implement.

Simply download the files, then place the /custom-gulp-commands/ folder in your Packages directory:

Mac :: Users\Username\Library\Application Support\Sublime Text 3\Packages

Windows :: C:\Users\Username\AppData\Roaming\Sublime Text 3\Packages

Then in the Sublime Command Palette, use the command: Gulp: Kill and Delete Cache

nicosantangelo commented 7 years ago

Awesome, thanks for the repo!