本文介紹了從 gulp 運(yùn)行 shell 命令的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時送ChatGPT賬號..
我想使用 gulp-shell
從 gulp 運(yùn)行 shell 命令.我看到 gulpfile 使用了以下成語.
I would like to run a shell command from gulp, using gulp-shell
. I see the following idiom being used the gulpfile.
這是從 gulp 任務(wù)運(yùn)行命令的慣用方式嗎?
Is this the idiomatic way to run a command from a gulp task?
var cmd = 'ls';
gulp.src('', {read: false})
.pipe(shell(cmd, {quiet: true}))
.on('error', function (err) {
gutil.log(err);
});
推薦答案
gulp-shell
已被列入黑名單.您應(yīng)該改用 gulp-exec,它也有更好的文檔.
gulp-shell
has been blacklisted. You should use gulp-exec instead, which has also a better documentation.
對于您的情況,它實際上說明了:
For your case it actually states:
注意:如果你只是想運(yùn)行一個命令,只運(yùn)行命令,不要使用這個插件:
Note: If you just want to run a command, just run the command, don't use this plugin:
var exec = require('child_process').exec;
gulp.task('task', function (cb) {
exec('ping localhost', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
})
這篇關(guān)于從 gulp 運(yùn)行 shell 命令的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!