grunt-phpcs
grunt-phpcs copied to clipboard
Validating single file with help of grunt-contrib-watch
Is it possible to run phpcs on changed files only?
I have tried the following inside Gruntfile.js, but it does not affect grunt-phpcs configuration at all:
grunt.event.on('watch', function (action, filepath) {
grunt.config.set('phpcs.application.dir', [filepath]);
});
Cheers
Hi,
if you want to modify config variables on the fly, you have to set
options: {
spawn: false
}
in your watch section. That's the magic.
Thanks, it helped in some way with changing the value of phpcs.application.dir, but phpcs task is not executing anymore. Changing it back to spawn: true fixes it, but the problem persists. Any ideas?
Thanks in advance
It should be working, my part of gruntfile is:
grunt.event.on('watch', function (action, filepath) { if (grunt.file.isMatch(grunt.config('watch.cs_strict.files'), filepath)) { grunt.config('phpcs.strict.dir', [filepath]); } });
Maybe just try to remove .set