grunt-phpcs icon indicating copy to clipboard operation
grunt-phpcs copied to clipboard

Validating single file with help of grunt-contrib-watch

Open pdrylo opened this issue 10 years ago • 3 comments

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

pdrylo avatar Oct 30 '14 11:10 pdrylo

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.

rolandba avatar Dec 07 '14 14:12 rolandba

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

pdrylo avatar Dec 12 '14 10:12 pdrylo

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

rolandba avatar Dec 12 '14 15:12 rolandba