gulp-html icon indicating copy to clipboard operation
gulp-html copied to clipboard

Output customizing

Open ghost opened this issue 4 years ago • 1 comments

Hi, I want to format the error output by handling the "error" event, but when using the "json" format, the event does not fire because a hard-coded formatter is used.

For example, validatorLog will only be called for { format: "gnu" }

const gulp = require('gulp')
const validator = require('gulp-html')

function validatorLog(e) {
    console.log('=== validatorLog ===')
    console.log(typeof e)
    console.log('=== validatorLog ===')
}

function validatorGnu() {
    return gulp.src('./index.html')
        .pipe(validator({ format: "gnu" }).on('error', validatorLog))
}

function validatorJson() {
    return gulp.src('./index.html')
        .pipe(validator({ format: "json" }).on('error', validatorLog))
}

exports.default = gulp.series(validatorGnu, validatorJson)

Also, this hard-coded formatter just prints json to the console. This is not a bug? image

ghost avatar Jan 22 '22 10:01 ghost

Happy to accept a PR that improves things, just CC me and I'll try to have a look. It always has been like that AFAICT.

XhmikosR avatar Feb 09 '22 15:02 XhmikosR