@@ -86,6 +86,9 @@ class Log extends Transform {
8686 }
8787}
8888
89+ let CLOSURE_LINT_ONLY = false ;
90+ let EXPECTED_WARNING_COUNT = 503 ;
91+
8992gulp . task ( 'closure' , [ 'clean' ] , ( ) => {
9093
9194 let entry , splitRx , joinRx ;
@@ -109,6 +112,25 @@ gulp.task('closure', ['clean'], () => {
109112 shell : `./${ entry } `
110113 } ) ;
111114
115+ function closureLintLogger ( log ) {
116+ let result = log . split ( / \n / ) . slice ( - 2 ) [ 0 ] ;
117+ let warnings = result . match ( / ( \d + ) w a r n i n g / ) ;
118+ let chalk = require ( 'chalk' ) ;
119+ if ( warnings && Number ( warnings [ 1 ] ) > EXPECTED_WARNING_COUNT ) {
120+ console . log ( log ) ;
121+ console . error ( chalk . red ( `closure linting: actual warning count ${ warnings [ 1 ] } greater than expected warning count ${ EXPECTED_WARNING_COUNT } ` ) ) ;
122+ process . exit ( 1 ) ;
123+ }
124+ }
125+
126+ let closurePluginOptions ;
127+
128+ if ( CLOSURE_LINT_ONLY ) {
129+ closurePluginOptions = {
130+ logger : closureLintLogger
131+ }
132+ }
133+
112134 const closureStream = closure ( {
113135 compilation_level : 'ADVANCED' ,
114136 language_in : 'ES6_STRICT' ,
@@ -118,6 +140,7 @@ gulp.task('closure', ['clean'], () => {
118140 assume_function_wrapper : true ,
119141 rewrite_polyfills : false ,
120142 new_type_inf : true ,
143+ checks_only : CLOSURE_LINT_ONLY ,
121144 externs : [
122145 'externs/webcomponents-externs.js' ,
123146 'externs/polymer-externs.js' ,
@@ -128,7 +151,7 @@ gulp.task('closure', ['clean'], () => {
128151 'polymerMixinClass' ,
129152 'polymerElement'
130153 ]
131- } ) ;
154+ } , closurePluginOptions ) ;
132155
133156 const closurePipeline = lazypipe ( )
134157 . pipe ( ( ) => closureStream )
@@ -186,6 +209,11 @@ gulp.task('closure', ['clean'], () => {
186209 . pipe ( gulp . dest ( COMPILED_DIR ) )
187210} ) ;
188211
212+ gulp . task ( 'lint-closure' , ( done ) => {
213+ CLOSURE_LINT_ONLY = true ;
214+ runseq ( 'closure' , done ) ;
215+ } )
216+
189217gulp . task ( 'build' , [ 'clean' ] , ( ) => {
190218 // process source files in the project
191219 const sources = project . sources ( ) ;
0 commit comments