我想为我的迁移设置生成器,如:
jake migration:create <name>
jake migration:remove <name>
jake migration:execute <name>
代码是
namespace('migration', function(){
desc('Create migration file');
task('create', [], function(params) {
console.log(arguments);
//some code for creation
});
desc('Remove migration file');
task('remove', [], function(params) {
console.log(arguments);
//some code for removing
});
desc('Execute migration file');
task('execute', [], function(params) {
console.log(arguments);
//some code for executing
});
});
但我没有找到如何在'namespaced'jake task中传递参数<name>
。
你能帮我吗?
UPD:
甚至来自https://github.com/isaacs/node-jake“将参数传递给jake”的示例对我来说都不适用,每次arguments
为空时,
有什么建议吗?
答案 0 :(得分:4)
您应该检查:https://github.com/mde/jake
以逗号分隔列表传递参数:
jake migration:创建[run,foo,bar]
然后将它们作为参数捕获它们:
namespace('migration', function(){
desc('Create migration file');
task('create', [], function(p1,p2,p3) {
console.log(p1,p2,p3);
//some code for creation
});
desc('Remove migration file');
task('remove', [], function(p1,p2,p3) {
console.log(p1,p2,p3);
//some code for removing
});
desc('Execute migration file');
task('execute', [], function(p1,p2,p3) {
console.log(p1,p2,p3);
//some code for executing
});
});