File tree Expand file tree Collapse file tree 2 files changed +31
-9
lines changed
Expand file tree Collapse file tree 2 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,13 @@ module.exports = {
5353 return this . _gzipFiles ( distDir , distFiles , filePattern , keep )
5454 . then ( function ( gzippedFiles ) {
5555 self . log ( 'gzipped ' + gzippedFiles . length + ' files ok' , { verbose : true } ) ;
56+ if ( keep ) {
57+ self . log ( 'keep is enabled, added gzipped files to `context.distFiles`' , { verbose : true } ) ;
58+ return {
59+ distFiles : gzippedFiles ,
60+ gzippedFiles : gzippedFiles
61+ }
62+ }
5663 return { gzippedFiles : gzippedFiles } ;
5764 } )
5865 . catch ( this . _errorMessage . bind ( this ) ) ;
Original file line number Diff line number Diff line change @@ -155,15 +155,30 @@ describe('gzip plugin', function() {
155155 } ) ;
156156 } ) ;
157157
158- it ( 'gzips the matching files with .gz suffix when keep is enabled' , function ( done ) {
159- context . config . gzip . keep = true ;
160- return assert . isFulfilled ( plugin . willUpload ( context ) )
161- . then ( function ( result ) {
162- assert . deepEqual ( result , { gzippedFiles : [ 'assets/foo.js.gz' ] } ) ;
163- done ( ) ;
164- } ) . catch ( function ( reason ) {
165- done ( reason ) ;
166- } ) ;
158+ describe ( 'when keep is enabled' , function ( ) {
159+ beforeEach ( function ( ) {
160+ context . config . gzip . keep = true ;
161+ } ) ;
162+
163+ it ( 'gzips the matching files with .gz suffix' , function ( done ) {
164+ return assert . isFulfilled ( plugin . willUpload ( context ) )
165+ . then ( function ( result ) {
166+ assert . deepEqual ( result . gzippedFiles , [ 'assets/foo.js.gz' ] ) ;
167+ done ( ) ;
168+ } ) . catch ( function ( reason ) {
169+ done ( reason ) ;
170+ } ) ;
171+ } ) ;
172+
173+ it ( 'adds the gzipped files to the distFiles' , function ( done ) {
174+ return assert . isFulfilled ( plugin . willUpload ( context ) )
175+ . then ( function ( result ) {
176+ assert . include ( result . distFiles , 'assets/foo.js.gz' ) ;
177+ done ( ) ;
178+ } ) . catch ( function ( reason ) {
179+ done ( reason ) ;
180+ } ) ;
181+ } ) ;
167182 } ) ;
168183 } ) ;
169184} ) ;
You can’t perform that action at this time.
0 commit comments