Closed mkormendy closed 6 years ago
I wanted this as well, and I have achieved it by setting a key binding to start my default gulp task.
{ "keys": ["command+shift+g"], "command": "gulp", "args": { "task_name": "default", "silent": true }}
By adding the silent tag, it doesn't bring up the panel, and cmd-shift-g will start gulp. Errors do bring up the panel as per default package settings.
What I don't like about this approach, however, is that I don't know if my default task is running at any given moment. If I go away for an hour and come back, I assume it is, but saving the file doesn't notify me that gulp has started. I have OS notifications for when it completes, which does help.
I wonder if there is a way to write in the little process bar in the bottom "gulp task running" when Default is indeed running.
I've got notifications working for me to let me know when what certain stages of my gulp build has completed. And I do have an errors catch as well but notifications is limited.
I wonder if sublime-gulp can catch those errors too and pop up accordingly based on them.
Hey, apologies for the radio silence.
@mkormendy error catching is a bit difficult. The package runs each gulp command as a subprocess (on a thread) which boils down to the following code:
stdout, stderr = process.communicate(...)
so I know something went wrong if stderr != None
but know what happened would require string parsing, which is not generic enough.
For reference the package runs the following code using stdout
and stderr
:
def finish(self, stdout, stderr):
finish_message = "gulp %s %s finished %s" % (self.task_name, self.task_flag, "with some errors." if stderr else "!")
self.status_message(finish_message)
if not self.silent:
# append in output
elif stderr and self.settings.get("show_silent_errors", False):
# Show stderr in output
@jacobraccuia I think that can be useful! We can use view. set_status()
(API on the View methods).
You can try it by opening your Sublime console (view -> show console
) and running sublime.active_window().active_view().set_status('Gulp', 'Gulp: Task running')
, sublime.active_window().active_view().erase_status('Gulp')
to delete it.
I think it should live behind a settings flag like show_status_bar
, but I'm not entirely sure how to display the information. Some options that come to mind:
Gulp: Task running
Gulp: Running 'start'
, and for more than one task Gulp: Running 'start', 'lint'
show_satus_bar_on_silent
What do you guys think?
@NicoSantangelo thanks for replying, I'm stoked now!
I agree that a setting would be best and the way you suggested to show the information is exactly how I'd suggest it. I do think that when Gulp is watching, it should say Gulp: Watching
.
@jacobraccuia yeah, I can make a special case for that command, as it's really common.
Ok! I can't promise when I'll get to do it, but I'll try to give it a go this weekend. Of course I'm more than open for contributions.
I'll let you guys know how it goes in this issue
I would agree with @jacobraccuia here. I think that "watching for watching" would be sufficient. :sweat_smile:
Ok I had some time today and I ended up with the following implementation (in a branch, not deployed)
Settings
// Can be either true, which will show all the running tasks on the status bar
// Or an array of task names to show, like ["watch"]
"status_bar_tasks": false
// Status bar message format, where {0} is the joined task names
"status_bar_format": "Gulp: {0}"
So for example running multiple gulp watch
tasks will lead to a single Gulp: watch
on the status bar. I didn't went with Gulp: Watching
because there were cases were the long running task was called server
. But that can be easily "faked" by using: status_bar_tasks: ["watch"]
and "status_bar_format": "Gulp watching"
If status_bar_tasks: true
and you run a build
task while watching, the status bar will show Gulp: watch, build
briefly until build ends and goes back to Gulp: watch
If you guys are still interested, I'd like to know what you think. I'm not 100% convinced it's the way to go @mkormendy @jacobraccuia Thanks!
@NicoSantangelo which branch should we pull to test?
status-bar-message, sorry!
Remember to update the status_bar_tasks
setting :)
Out on v6.1.3!
This works great, thank you so much!
Yes this works awesome as implemented. At first, it was a bit confusing, but now I get it and I think I should change the way my gulp process works.
It'd be nice to hide the output panel and work on my code, but when there's an issue with the task, be it code compiling, minification, etc., the output panel would then open up revealing the messages.