jharding / grunt-exec

Grunt plugin for executing shell commands.
https://npmjs.org/package/grunt-exec
Other
248 stars 47 forks source link

Problem with arguments #27

Closed jgauna closed 10 years ago

jgauna commented 11 years ago

Hi,

I'm trying to pass arguments and it works OK but if I define a block of tasks like:

 exec: {
      commit: {
        cmd: function(mensaje) {          
          return 'echo Mensaje: ' + mensaje;
        }
      }
    },

[...]

grunt.registerTask('pre-commit', [
    'clean',
    'jshint',
    'exec'
  ]);

The arguments won't work.

I'm running it like this:

grunt pre-commit:PARAMETRO

and it's showing undefined. Do you know how to do this?

Thanks in advance.

jharding commented 11 years ago

You could do something like:

grunt.registerTask('pre-commit', function(arg) {
  grunt.task.run([
    'clean',
    'jshint',
    'exec:commit:' + arg
  ]);
})

By no means a elegant solution, but that's worked for me in the past.