This repository was archived by the owner on Jan 31, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -60,10 +60,6 @@ const defaultOptions = {
6060const preprocessor = ( options = { } ) => {
6161 log ( 'received user options' , options )
6262
63- // allow user to override default options
64- const browserifyOptions = Object . assign ( { } , defaultOptions . browserifyOptions , options . browserifyOptions )
65- const watchifyOptions = Object . assign ( { } , defaultOptions . watchifyOptions , options . watchifyOptions )
66-
6763 // we return function that accepts the arguments provided by
6864 // the event 'file:preprocessor'
6965 //
@@ -95,6 +91,10 @@ const preprocessor = (options = {}) => {
9591 log ( `input: ${ filePath } ` )
9692 log ( `output: ${ outputPath } ` )
9793
94+ // allow user to override default options
95+ const browserifyOptions = Object . assign ( { } , defaultOptions . browserifyOptions , options . browserifyOptions )
96+ const watchifyOptions = Object . assign ( { } , defaultOptions . watchifyOptions , options . watchifyOptions )
97+
9898 // we need to override and control entries
9999 Object . assign ( browserifyOptions , {
100100 entries : [ filePath ] ,
Original file line number Diff line number Diff line change @@ -119,6 +119,26 @@ describe('browserify preprocessor', function () {
119119 } )
120120 } )
121121
122+ it ( 'starts with clean cache and packageCache' , function ( ) {
123+ browserify . reset ( )
124+ browserify . returns ( this . bundlerApi )
125+
126+ const run = preprocessor ( this . options )
127+ return run ( this . file )
128+ . then ( ( ) => {
129+ browserify . lastCall . args [ 0 ] . cache = { foo : 'bar' }
130+ browserify . lastCall . args [ 0 ] . packageCache = { foo : 'bar' }
131+ this . file . on . withArgs ( 'close' ) . yield ( )
132+
133+ return run ( this . file )
134+ } )
135+ . then ( ( ) => {
136+ expect ( browserify ) . to . be . calledTwice
137+ expect ( browserify . lastCall . args [ 0 ] . cache ) . to . eql ( { } )
138+ expect ( browserify . lastCall . args [ 0 ] . packageCache ) . to . eql ( { } )
139+ } )
140+ } )
141+
122142 it ( 'watches when shouldWatch is true' , function ( ) {
123143 this . file . shouldWatch = true
124144 return this . run ( ) . then ( ( ) => {
@@ -166,7 +186,7 @@ describe('browserify preprocessor', function () {
166186 } )
167187
168188 it ( 'uses transforms if provided' , function ( ) {
169- const transform = [ ( ) => { } , { } ]
189+ const transform = [ ( ) => { } , { } ]
170190 this . options . browserifyOptions = { transform }
171191 return this . run ( ) . then ( ( ) => {
172192 expect ( browserify . lastCall . args [ 0 ] . transform ) . to . eql ( transform )
You can’t perform that action at this time.
0 commit comments