0

I'm after this object: https://github.com/gruntjs/grunt-contrib-watch/blob/master/tasks/watch.js#L33

so I can pass that string into this subtask (I'm using grunt-shell and write-good):

grunt.initConfig({
shell: {
  checkAll: {
    command: 'write-good *.md --no-passive',
    options: {
      //callback: checkForErrors
    }
  },
  checkSpecified: {
    command: 'write-good <%= filepath %> --no-passive',
    options: {
      //callback: checkForErrors
    }
  }
},

watch: {
  docs: {
    files: '**/*.md',
    tasks: ['shell:checkSpecified'],
    options: {
      livereload: true
    }
  }
}
});

grunt.registerTask('default', "Checking for good prose, excluding passive voice.", function(){
  grunt.task.run('shell:checkAll', 'watch');
});

Hoping the Grunt maintainers will see this relatively crude idea and give me a hand :) I'm on OS X 10.9.4, please let me know if I can provide any other relevant info.

JaKXz
  • 1,665
  • 1
  • 14
  • 34
  • Okay, so I have the filepath using `grunt.event.on('watch', function(action, filepath){});`, but now I don't know how to [set the property `filepath.name`](http://gruntjs.com/api/grunt.config#grunt.config.set) (and perhaps require it) before the `checkSpecified` task executes. – JaKXz Jul 23 '14 at 07:47
  • `grunt.config.set('filepath', filepath);` puts the name into the config object but using `<%= filepath %>` in the command string is failing because it thinks I'm not specifying a file... but in my `on watch` function I can get the config object and see it specified a proper file name. I'm so close! – JaKXz Jul 23 '14 at 08:02
  • Another update: I'm using `grunt.config.set('filepath', grunt.config.escape(filepath));` since all the filenames have `.`s in them. Still no luck though :( – JaKXz Jul 23 '14 at 08:23
  • Got it! https://gist.github.com/JaKXz/aaa17d44947554144d3e/revisions#diff-35b4a816e0441e6a375cd925af50752cR23 Credit to [this answer](https://stackoverflow.com/a/17960306/1444541) for the last piece. – JaKXz Jul 23 '14 at 08:39

0 Answers0