Gruntjs 获取更改文件的文件路径-grunt watch livereload
我在追求这个目标: 因此,我可以将该字符串传递到此子任务(我使用and):Gruntjs 获取更改文件的文件路径-grunt watch livereload,gruntjs,grunt-contrib-watch,Gruntjs,Grunt Contrib Watch,我在追求这个目标: 因此,我可以将该字符串传递到此子任务(我使用and): grunt.initConfig({ 外壳:{ 全选:{ 命令:“write good*.md--无被动”, 选项:{ //回调:checkForErrors } }, 选中指定的复选框:{ 命令:“写得好——不要被动”, 选项:{ //回调:checkForErrors } } }, 观察:{ 文件:{ 文件:'***.md', 任务:['shell:checkSpecified'], 选项:{ 利弗雷罗德:没错 }
grunt.initConfig({
外壳:{
全选:{
命令:“write good*.md--无被动”,
选项:{
//回调:checkForErrors
}
},
选中指定的复选框:{
命令:“写得好——不要被动”,
选项:{
//回调:checkForErrors
}
}
},
观察:{
文件:{
文件:'***.md',
任务:['shell:checkSpecified'],
选项:{
利弗雷罗德:没错
}
}
}
});
registerTask('default',“检查好的散文,不包括被动语态。”,function(){
run('shell:checkAll','watch');
});
希望Grunt维护人员能看到这个相对粗糙的想法,并帮我一把:)我使用的是OS X 10.9.4,如果我能提供任何其他相关信息,请告诉我。明白了
最后一部分归功于。好的,因此我使用('watch',function(action,filepath){})获得了文件路径,但现在我不知道如何(可能需要它)在执行
检查指定的任务之前执行。grunt.config.set('filepath',filepath)
将名称放入config对象,但在命令字符串中使用
失败,因为它认为我没有指定文件。。。但是在我的on-watch
函数中,我可以获得config对象,并看到它被指定了一个正确的文件名。我好近啊!另一个更新:我正在使用grunt.config.set('filepath',grunt.config.escape(filepath))因为所有文件名中都有
s。但还是没有运气:(
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');
});