2011-09-11 97 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 
    }); 

}); 
相關問題