Closed matthias-vogt closed 8 years ago
Hm, do you mean have a flag for every command you run?
Right now if you want to run a command with a specific flag, you could use "flags"
on your settings like this:
{
"flags": {
"build": "--watch"
}
}
in this example, when you run build
, it'll execute gulp build --watch
.
I mean a flag for the gulp command itself. Running a command with the flag won't change the way Gulp runs but rather the command.
Setting a --gulpfile
flag command specific for example wouldn't work because it wouldn't find a gulpfile to run the task in.
It would run gulp task --gulpfile gulpfile_foo.js
instead of gulp --gulpfile gulpfile_foo.js task
Ooh, got it.
I'll keep this on the roadmap, while I'm finishing a few new features. For now, you could use arbitrary tasks (which will be on the next release). When asked which task to run you'll be able to write --gulpfile gulpfile_foo.js task
Thanks for the suggestion!
Sweet. Will the arbitrary tasks also be able to be run via keyboard shortcuts btw?
Kind of, you can add a shortcut to the command itself:
{ "keys": ["KEYS"], "command": "gulp_arbitrary" }
Which will trigger the prompt each time.
Another way to do it (which works with the current version) is:
{ "keys": ["KEYS"], "command": "gulp", "args": { "task_name": "--gulpfile gulpfile_foo.js task" } }
that will always run gulp --gulpfile gulpfile_foo.js task
every time you press KEYS
I actually tried that before and it still doesn't work for me…
My keymap is: { "keys": ["alt+g"], "command": "gulp", "args": { "task_name": "--gulpfile gulpfile_foo.js default" } }
and when I press the keys, the console says: error: Gulp: gulpfile.js not found!
and I get an error prompt.
Running the command gulp --gulpfile gulpfile_foo.js default
from the commandline works perfectly fine, though. Any ideas?
Hmm I think that's because Sublime isn't running gulp
in the context of your folder...you could try listing the entire path to gulpfile_foo.js
, like: { "keys": ["alt+g"], "command": "gulp", "args": { "task_name": "--gulpfile /full/path/to/gulpfile_foo.js default" } }
(I know, not pretty):
Still doesn't work, sadly. My keybinding is now: { "keys": ["alt+g"], "command": "gulp", "args": { "task_name": "--gulpfile /Applications/MAMP/htdocs/gulpfile_foo.js default" } }
Oh ok. So just I don't bother you with more tests, could you describe me your use case?
I know you're trying to run gulp --gulpfile /Applications/MAMP/htdocs/gulpfile_foo.js default
but it'll be really helpful to know how your project looks and what is your desired result (thanks :) )
Well,
I want to have two seperate gulpfiles, one for the git repo and one for myself because there is sensitive information stored in it. Thus, the idea is to create a seperate gulpfile with gulp (gulpception), without the sensitive bits. The original file should be called gulpfile_foo.js
and the other one gulpfile.js
.
So in order to run the correct gulpfile, I need to be able to specify the gulpfile flag.
I could also approach the problem like this: (require()
the gulpfile from another gulpfile) https://github.com/gulpjs/gulp/blob/9712a877f97ca67a35892906187bcd0aab286c3b/docs/recipes/specifying-a-different-gulpfile.md
…but it's less slick as it requires an additional file ;)
I'm currently using MAMP on OS X for a local webserver, that's why the path to my gulpfile is /Applications/MAMP/htdocs/gulpfile_foo.js
.
I don't mind any tests at all :)
Did you get it to work on your machine btw?
Sorry for the delay.
Ok so when you use Sublime you have your git repo on the sidebar but there's no reference to a gulpfile.js
file, correct?
If I understood correctly, currently you can't run gulp with this package (I've never considered this scenario). I'll try to do something about it, but I want to finish a few things first.
Just as a workaround, if you rename gulpfile_foo.js
to gulpfile.js
and run gulp using your keybinding, does it work?
Did you get it to work on your machine btw?
Nope! I didn't recreate the situation well enough.
Yeah, if I use a gulpfile with the name gulpfile.js and then create another gulpfile with a different name with gulp, it works. But I don't want any contributors to have my problem ;)
I'm back!
If you're still there, I was thinking of adding a force
flag on the settings. By default it should be false
, but if it's set to true
, Sublime Gulp
will ignore the fact that a gulpfile.js
is not found and run anyways.
That should help with this kind of edge cases wont it?
Yeah, that would be an option. But what would happen if the gulpfile
specified in the keybinding didn't exist?
Another approach could be to leave the error reporting to gulp
, not checking if a gulpfile.js
exists and just displaying gulp
's error notice in case the file isn't found – if that's possible.
Sorry for the late reply.
Yeah, I think that's best. I'm going to add it as a setting anyways because a lot of people already downloaded Sublime Gulp
and I don't want to change a core feature but I think I'll add a check_for_gulpfile: true/false
setting.
If set to false, the package will leave the error reporting to gulp
That sounds great. I think when writing wrappers around existing software, it's best practice to get out of the way as much as possible and just connect the APIs – in this case leaving as much error reporting as possible to gulp
.
So if you added this feature, would the mightyful { "keys": ["keys"], "command": "gulp", "args": { "task_name": "--gulpfile /path/to/gulpfile_foo.js default" } }
work?
That sounds great. I think when writing wrappers around existing software, it's best practice to get out of the way as much as possible and just connect the APIs – in this case leaving as much error reporting as possible to gulp.
Yep, agreed. Sublime gulp started using the default Sublime Text Build System (instead of a custom Process like it does now), which didn't allow for failing processes to report back the result, so that's why it alerted the user before running. I never ended up changing it.
So if you added this feature, would the mightyful { "keys": ["keys"], "command": "gulp", "args": { "task_name": "--gulpfile /path/to/gulpfile_foo.js default" } } work?
That's the idea!. I'll test the feature with that same command :)
Awesome, thanks a bunch. Looking forward to the release :)
This should be up! ( release 5.1.0
)
The new setting is check_for_gulpfile, in you case you should set it to false
!
The release does not have a message because I plan to add per-project settings soon and I want to wait until that's done to let users know of both things, but you can start using the setting now!
Let me know how it goes, I am going to close this issue but if you have any problem/request I'll re open it. Thanks a lot for the help and patience.
It would be great if we could have the ability to add more flags to the gulp command, for example "gulpfile" to specify a custom gulpfile or "no-color". Perhaps by adding an option for each supported flag in the settings similarly to how cwd flag is handled with "gulpfile_paths"? List of gulp flags: https://github.com/gulpjs/gulp/blob/master/docs/CLI.md