I'm using gulp to compile pug files to HTML. The issue is, if there's a syntax error, like bad indentation or duplicate attributes for example, it will output the entire PUG file content to the terminal. My pug file is really big, like >1000 lines, and can't fit in the terminal memory. Hence, the part of the error message that prints the actual line which states where and what the syntax error is, disappears.
Rudimentary example:
[15:23:15] 'convertPUGToHTML' errored after 214 ms
[15:23:15] Error in plugin "gulp-pug"
Message:
/Users/../../../pug/partials/_head.pug:2:22
1| title Component Reference
> 2| meta(charset="utf-8" charset="8")
----------------------------^
3| meta(http-equiv="X-UA-Compatible", content="IE=edge")
4| meta(http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate")
5| meta(http-equiv="Expires" content="0")
Duplicate attribute "charset" is not allowed.
Details:
code: PUG:DUPLICATE_ATTRIBUTE
msg: Duplicate attribute "charset" is not allowed.
line: 2
column: 22
filename: /Users/../../../partials/_head.pug
src: /* pug compiler will print entire fill content here.
If it's more than say 60lines, the actual error message above will disappear */
In the above example, to showcase the issue, I added a duplicate charset attribute to meta, which threw the error. Since my _head.pug is really small, I can see the part which shows the exact line number & position, and what the error actually is. However for really big pug files, the error message will disappear. I want to prevent gulp-pug from outputting the entire file content.
The two options that I felt might help based on the api reference didn't work either:
function convertPUGToHTML() {
return gulp.src(['./pug/*.pug'])
.pipe(pug({
debug: false,
compileDebug: false,
}))
.pipe(gulp.dest('./build/'))
}
Does anyone know how to stop it from printing the entire file content to terminal, so it will only print the actual line with error?