This repository was archived by the owner on Jul 19, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ Error: HTML validation error(s) found
7575```
7676
7777## 4) Options
78+ ### analyzer()
7879| Option | Type | Description | Default |
7980| ----------------- | ---------- | ----------------------------------------------------------------------------------------------------------- | ------- |
8081| ** proxy** | ` string ` | HTTP address of the proxy server if you are running behind a firewall, e.g. ` 'http://proxy:8080' ` | ` null ` |
@@ -95,6 +96,11 @@ const task = {
9596 };
9697```
9798
99+ ### reporter()
100+ | Option | Type | Description | Default |
101+ | --------------- | --------- | ------------------------------------------------------------------------------------- | ------- |
102+ | ** throwErrors** | ` boolean ` | Throw an [ error] ( https://github.com/gulpjs/plugin-error ) on HTTP validation failure. | ` false ` |
103+
98104## 5) Deprecated CommonJS (gulp-w3c-html-validator v2.0)
99105If your build system is using ` require() ` statements for CommonJS modules, install the older v2.0:
100106``` shell
Original file line number Diff line number Diff line change @@ -100,10 +100,12 @@ const htmlValidator = {
100100 return through2 . obj ( transform ) ;
101101 } ,
102102
103- reporter ( ) {
103+ reporter ( options ) {
104+ const defaults = { throwErrors : false } ;
105+ const settings = { ...defaults , ...options } ;
104106 const transform = ( file , encoding , done ) => {
105107 done ( null , file ) ;
106- if ( file . validationResults && ! file . validationResults . success )
108+ if ( settings . throwErrors && file . validationResults && ! file . validationResults . success )
107109 throw new PluginError ( pluginName , 'HTML validation failed' ) ;
108110 } ;
109111 return through2 . obj ( transform ) ;
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ describe('The htmlValidator.reporter() function', () => {
143143 success : false ,
144144 messages : [ 'HTML is valid' ]
145145 } ;
146- const stream = htmlValidator . reporter ( ) ;
146+ const stream = htmlValidator . reporter ( { throwErrors : true } ) ;
147147 const writeToStream = ( ) => stream . write ( mockFile ) ;
148148 writeToStream . should . throw ( / H T M L v a l i d a t i o n f a i l e d / ) ;
149149 stream . end ( ) ;
You can’t perform that action at this time.
0 commit comments