phplint
phplint copied to clipboard
Using phplint with gulp.src and pipe
Is it possible to use phplint with gulp.src and pipe?
For example, I would like to do something along the lines of:
gulp.task('php', php);
function php(callback) {
return gulp.src(['src/**/*.php'])
.pipe(phpStuff1)
.pipe(phpStuff2)
.pipe(phplint({limit: 10}))
.pipe(phpStuff3)
.pipe(gulp.dest('dist'));
};
hey @MatthewHerbst, that's definitely worth looking into, I'll check it out :)
Awesome, thanks! Let me know if I can help in any way - happy to contribute where I can.
@MatthewHerbst FYI - whilst this is being implemented I made a workaround for this using gulp-shell
gulp.task('php-lint', function () {
return gulp.src('theme/*.php', {read: false})
.pipe(plumber({ errorHandler: handleError } ))
.pipe(shell(['php -l theme/<%= file.relative %>'], {
templateData: {
e: function (s) {
s = s.split(/\n/);
return s[1];
}
},
quiet: true,
errorMessage: '[PHP LINT] <%= e(error.message) %>'
}))
.pipe(notify({
title: 'PHP LINT'
}));
})
plumber catches the customised error message (which just strips the redundant file path info) whilst the quiet flag suppresses the normal output of the command =)
@DaveVP that's pretty cool, thanks!
In terms of phplint
supporting gulp stream in the future, would this be the right way to go about in the source code, or is there a more "native" way to do it? I'm thinking we should just make a pr for it.