I would like to run a shell command from gulp, using gulp-shell
. I see the following idiom being used the gulpfile.
Is this the idiomatic way to run a command from a gulp task?
JavaScript
x
7
1
var cmd = 'ls';
2
gulp.src('', {read: false})
3
.pipe(shell(cmd, {quiet: true}))
4
.on('error', function (err) {
5
gutil.log(err);
6
});
7
Advertisement
Answer
gulp-shell
has been blacklisted. You should use gulp-exec instead, which has also a better documentation.
For your case it actually states:
Note: If you just want to run a command, just run the command, don’t use this plugin:
JavaScript
1
10
10
1
var exec = require('child_process').exec;
2
3
gulp.task('task', function (cb) {
4
exec('ping localhost', function (err, stdout, stderr) {
5
console.log(stdout);
6
console.log(stderr);
7
cb(err);
8
});
9
})
10