Jav*_*eva 1 node.js gruntjs yeoman yeoman-generator
基本上我想grunt在我的生成器完成安装依赖项后运行,我发现你可以callback在installDependencies方法之后添加一个函数,以便在安装完所有内容之后运行:
this.on('end', function () {
this.installDependencies({
skipInstall: options['skip-install'],
callback: function () {
console.log('All done!');
}
});
});
Run Code Online (Sandbox Code Playgroud)
但是我不确定如何运行grunt任务(如去往终端并运行"grunt")
小智 5
在this.on('end')之后添加这一行
// Now you can bind to the dependencies installed event
this.on('dependenciesInstalled', function() {
this.spawnCommand('grunt', ['build']);
});
Run Code Online (Sandbox Code Playgroud)
查看此主题以获取更多详细信息
但是,如果你正在使用最新的yeomen更新,你需要这样做
this.on('end', function () {
if (!this.options['skip-install']) {
this.npmInstall();
this.spawnCommand('grunt', ['prepare']); // change 'prepare' with your task.
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1298 次 |
| 最近记录: |