基本上我想在生成器完成安装依赖项后运行grunt
,我发现你可以在callback
方法中添加installDependencies
函数,以便在安装完所有内容后运行像这样:
this.on('end', function () {
this.installDependencies({
skipInstall: options['skip-install'],
callback: function () {
console.log('All done!');
}
});
});
但是我不确定如何运行grunt
任务(如去往终端并运行“grunt”)
答案 0 :(得分:5)
在this.on('end')之后添加这行
// Now you can bind to the dependencies installed event
this.on('dependenciesInstalled', function() {
this.spawnCommand('grunt', ['build']);
});
查看此topic了解详情。
但是如果你使用的是最新的yeomen更新,你需要像这样做
this.on('end', function () {
if (!this.options['skip-install']) {
this.npmInstall();
this.spawnCommand('grunt', ['prepare']); // change 'prepare' with your task.
}
});