jharding / grunt-exec

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

allow callback function before test if string #5

Closed AlbanMinassian closed 12 years ago

AlbanMinassian commented 12 years ago

allow use function to generate string command. Cordialy Ami44

jharding commented 12 years ago

This seems fine, but could you give me a use case for this?

AlbanMinassian commented 12 years ago

hello

exec: {
    replace: {
        command: function () { return 'sed -i \'s/ugly/'+grunt.template.process('<%= pkg.author %>')+'/g\' file.txt'; }
    }
}        
jharding commented 12 years ago

Cool, there are probably a few use cases where this would be useful. Rather than relying on the closure to get access to grunt, I'll pass grunt to the function. So it'd look something like this:

exec: {
  replace: {
    command: function(grunt) {  
      return 'sed -i \'s/ugly/'+grunt.template.process('<%= pkg.author %>')+'/g\' file.txt';
    }
  }
}

I'm pretty busy this week, but I'll try and get this in and release the next version of grunt-exec by next week.

jharding commented 12 years ago

This is now in v0.3.0.

AlbanMinassian commented 12 years ago

Thank @jharding