Gulp 承诺解决后的吞咽运行序列
主任务提供给用户,以便在每次运行任务之前输入登录名和密码。所以我尝试使用承诺,但在这种情况下,我的序列不会启动,因为当承诺解决时,任务就完成了Gulp 承诺解决后的吞咽运行序列,gulp,es6-promise,Gulp,Es6 Promise,主任务提供给用户,以便在每次运行任务之前输入登录名和密码。所以我尝试使用承诺,但在这种情况下,我的序列不会启动,因为当承诺解决时,任务就完成了 export default function() { var loginPromise = new Promise((resolve, reject) => { inquirer.prompt(config.loginQuestions).then(answer => { if (!(answ
export default function() {
var loginPromise = new Promise((resolve, reject) => {
inquirer.prompt(config.loginQuestions).then(answer => {
if (!(answer.login.length && answer.password.length)) {
reject('loginError')
} else {
resolve(answer)
}
});
});
return loginPromise;
};
和任务
import login from '../util/login';
gulp.task('sassComponents', function() {
return login().then(function(answer) {
console.log('started') //This code executed and i see console
return gulp.src(conf.sassPath)
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(autoprefixer(config.autoprefixer))
.pipe(sourcemaps.write())
.pipe(gulp.dest(function(file) {
return destPath(file) // destPath doesn`t start
}))
})
});
因此,login()是第一个函数的执行。然后出现控制台,但未启动destPath。也许你知道怎么修吗