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 = {
53
53
return this . _gzipFiles ( distDir , distFiles , filePattern , keep )
54
54
. then ( function ( gzippedFiles ) {
55
55
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
+ }
56
63
return { gzippedFiles : gzippedFiles } ;
57
64
} )
58
65
. catch ( this . _errorMessage . bind ( this ) ) ;
Original file line number Diff line number Diff line change @@ -155,15 +155,30 @@ describe('gzip plugin', function() {
155
155
} ) ;
156
156
} ) ;
157
157
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
+ } ) ;
167
182
} ) ;
168
183
} ) ;
169
184
} ) ;
You can’t perform that action at this time.
0 commit comments