【发布时间】: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 propertyfilepath.name(也许需要它)。 -
grunt.config.set('filepath', filepath);将名称放入配置对象,但在命令字符串中使用<%= filepath %>失败,因为它认为我没有指定文件......但在我的on watch函数中我可以获取配置对象并查看它指定了正确的文件名。我很近! -
另一个更新:我正在使用
grunt.config.set('filepath', grunt.config.escape(filepath));,因为所有文件名都包含.s。不过还是没有运气:(
标签: gruntjs grunt-contrib-watch