2011-09-11 94 views
2

我想有发电机,我喜欢的迁移:如何将参数传递给像那样的名字空间的jake任务:任务参数?

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 
    }); 

}); 

,但我没有找到如何通过参数<name>'namespaced'jake ta内SK。 你能帮我吗?

UPD: 甚至https://github.com/isaacs/node-jake例子“将参数传递给杰克”不工作对我来说,每一次arguments是空的, 什么建议吗?

回答

4

您应该检查:https://github.com/mde/jake

您传递参数以逗号分隔的列表:

杰克迁移:创建[行程,FOO,巴]

,然后赶上他们在你的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 
    }); 

}); 
相关问题