虽然过去常常使用Rakefile,Cakefile和Jakefile,但它们都有一些方便的列出可用任务的方法.
喜欢
jake -T
jake db:dump # Dump the database
jake db:load # Populate the database
Run Code Online (Sandbox Code Playgroud)
..等等.
甚至过滤"jake -T dum",只显示"the jake db:dump"任务.
那么,有没有办法使用grunt做同样的事情?我在考虑创建一个默认任务,迭代整个grunt配置对象并通过console.log将其写入stdout,但有人知道更好的方法吗?
谢谢.
我想创建一个Jakefile,它编译一些CoffeeScripts来安装NodeJS应用程序.
你是怎样做的?
我尝试过:https: //gist.github.com/1241827
但这是一种微弱的方法,绝对不是优雅的.
任何提示?
Jake任务执行长时间运行的系统命令.另一项任务取决于在开始之前完成的第一项任务.'child_process'的'exec'功能异步执行系统命令,使得第二个任务可以在第一个任务完成之前开始.
编写Jakefile以确保第一个任务中长时间运行的系统命令在第二个任务启动之前完成的最简洁方法是什么?
我已经考虑过在第一个任务结束时在虚拟循环中使用轮询,但这只是闻起来很糟糕.似乎必须有更好的方法.我已经看到了这个问题,但它并没有完全解决我的问题.
var exec = require('child_process').exec;
desc('first task');
task('first', [], function(params) {
exec('long running system command');
});
desc('second task');
task('second', ['first'], function(params) {
// do something dependent on the completion of 'first' task
});
Run Code Online (Sandbox Code Playgroud)