【问题标题】:Get filepath of changed files - grunt watch livereload获取更改文件的文件路径 - grunt watch livereload
【发布时间】:2014-07-23 06:12:48
【问题描述】:

我在寻找这个对象:https://github.com/gruntjs/grunt-contrib-watch/blob/master/tasks/watch.js#L33

所以我可以将该字符串传递给这个子任务(我正在使用grunt-shell 和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');
});

希望 Grunt 维护者能看到这个相对粗略的想法并帮助我:) 我使用的是 OS X 10.9.4,如果我可以提供任何其他相关信息,请告诉我。

【问题讨论】:

  • 好的,所以我有使用grunt.event.on('watch', function(action, filepath){}); 的文件路径,但现在我不知道如何在checkSpecified 任务执行之前使用set the property filepath.name(也许需要它)。
  • grunt.config.set('filepath', filepath); 将名称放入配置对象,但在命令字符串中使用 &lt;%= filepath %&gt; 失败,因为它认为我没有指定文件......但在我的 on watch 函数中我可以获取配置对象并查看它指定了正确的文件名。我很近!
  • 另一个更新:我正在使用grunt.config.set('filepath', grunt.config.escape(filepath));,因为所有文件名都包含.s。不过还是没有运气:(

标签: gruntjs grunt-contrib-watch


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-29
相关资源
最近更新 更多