I would like to have generators for my migration like:
我希望我的迁移有发电机,比如:
jake migration:create <name>
杰克迁移:创建 <名称>
jake migration:remove <name>
杰克迁移:删除 <名称>
jake migration:execute <name>
杰克迁移:执行 <名称>
code is
代码是
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
});
});
but I didn't find how to pass parameter <name>
inside 'namespaced' jake task. Could you please help me?
但是我没有找到如何在“名称空间”的jake任务中传递参数
UPD: even examples from https://github.com/isaacs/node-jake "Passing parameters to jake" doesn't work for me, every time arguments
is empty, any suggestion?
UPD:即使是https://github.com/isaacs/node-jake“将参数传递给jake”的例子对我也不起作用,每次参数为空时,有什么建议吗?
1 个解决方案
#1
4
You should check: https://github.com/mde/jake
您应该检查:https://github.com/mde/jake
You pass parameters as comma separated list:
您将参数作为逗号分隔的列表传递:
jake migration:create[run,foo,bar]
杰克迁移:创建(跑,foo,酒吧)
and then catch them in you function as params:
然后在你的身体中捕捉它们,就像params一样:
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
});
});
#1
4
You should check: https://github.com/mde/jake
您应该检查:https://github.com/mde/jake
You pass parameters as comma separated list:
您将参数作为逗号分隔的列表传递:
jake migration:create[run,foo,bar]
杰克迁移:创建(跑,foo,酒吧)
and then catch them in you function as params:
然后在你的身体中捕捉它们,就像params一样:
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
});
});