2

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?

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?

il ragazzo
  • 61
  • 1
  • 7

1 Answers1

4

You should check: https://github.com/mde/jake

You pass parameters as comma separated list:

jake migration:create[run,foo,bar]

and then catch them in you function as 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
  });

});
Kuddl
  • 73
  • 4