-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add clarification to the README #55
Comments
Yes, I know it's weird to pass But many people are doing so because the |
@sun-zheng-an Why not make another module that simply runs a command that wraps child_process.exec? |
Because it's weird to include two different module for running shell command in
I tell people use this anti-pattern just for convenience (I know it's weird, but it works for a long time). Can I tell people to use |
@sun-zheng-an It isn't weird at all to include two different modules that do two different things. One is for running commands as a stream, one is just for running commands. Making this module do both things is crazy and you are causing a bunch of people to do really stupid things by telling them to do something they absolutely shouldn't be doing. We will do everything possible in gulp 4.0 to stop people from using plugins in this way, including erroring on dummy |
Could you give me docs or discussions for explaining why this is considered harmful? I will put it into the clarification. |
From gulpjs/gulp#1353 @contra I have never closed this issue at all and keep waiting for your reply. |
Based on this comment gulpjs/gulp#1353 (comment) It looks like the following code is an alternative to gulp-shell that is not an anti-pattern. var spawn = require('child_process').spawn;
gulp.task('example', ['dependency'], function(cb) {
var flags = [
'--path',
'some/path',
'--verbose'
];
var cmd = spawn('some-command', flags, {stdio: 'inherit'});
return cmd.on('close', cb);
}); |
@JohnAlbin Sure, if you want to write it in the most verbose way possible. You'd be better off using any of the tens of modules that make that sample one line of code (ie https://github.com/danielhusar/exec-chainable): gulp.task('example', ['dependency'], function(){
return exec('some-command --path some/path --verbose');
}); or in coffee gulp.task 'example', -> exec 'whatever-command --arg=1' I made this same point a few comments ago: there is no reason for running a command to be a gulp plugin if you are not running the command based on files in the stream. It's faster, simpler, cleaner, and more maintainable to just run a command using standard practices than to do some crazy hack with streams. |
@contra I was just providing an example for others to follow since no one else had done so and it took me a while to figure it out. Thank you for another example, though I won't use a module that is on v0.0.3. I prefer Node.js authors that will commit to supporting a semver-friendly 1.0 API in their modules. I'll stick with core Node.js APIs for this particular problem. Here's a good comparison of spawn vs. exec that (while old) is really useful if others are unfamiliar with them (as I was). http://www.hacksparrow.com/difference-between-spawn-and-exec-of-node-js-child_process.html BTW, even though I just stopped using this gulp plugin, I still don't know why the things it does are an anti-pattern. Neither does @sun-zheng-an (see #55 (comment) above.) Is it just that there are existing npm modules that can do this without being gulp-specific? or is there some other anti-pattern you were referring to? |
@JohnAlbin Okay, it was a random module out of hundreds that popped up when searching "exec" on npm. We don't need to discuss opinions about semantic versioning. I've outlined why it is an anti-pattern like ten times in this issue, I don't understand how I can be any clearer:
I opened this issue as a courtesy to let everyone know that this anti-pattern has been invalidated in an upcoming release, and the code you are recommending will stop working. I'm going to close this now because I don't think there is anywhere to go from here. The change has been made, everyone has been informed. |
Well doing something like 'child-process'.spawn is kinda upside down. I have yet to come across a real Definition of an anti-pattern that also explains why Dependency INjection is no anti-pattern. Biggest security-leak imo. |
google/material-design-lite#790
People are using this in weird ways, can you add a clarification to the README that this module should only be used if:
and to use child_process otherwise?
Empty globs will start throwing errors in 4.0 as well. Thanks!
The text was updated successfully, but these errors were encountered: