File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -197,13 +197,17 @@ GitWrappedFs.patchInPlace = function (fs) {
197197 gitWrappedFs = new GitWrappedFs ( ) ;
198198 _ . extend ( fs , gitWrappedFs ) ;
199199 fs . unpatch = function ( ) {
200+ if ( 'unpatch' in fsShallowCopy ) {
201+ fs . unpatch = fsShallowCopy . unpatch ;
202+ } else {
203+ delete fs . unpatch ;
204+ }
200205 Object . keys ( gitWrappedFs ) . forEach ( function ( propertyName ) {
201206 if ( propertyName in fsShallowCopy ) {
202207 fs [ propertyName ] = fsShallowCopy [ propertyName ] ;
203208 } else {
204209 delete fs [ propertyName ] ;
205210 }
206211 } ) ;
207- delete fs . unpatch ;
208212 } ;
209213} ;
Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ describe('GitWrappedFs', function () {
145145
146146 describe ( 'patching the built-in fs module "in-place"' , function ( ) {
147147 var originalReadFile = require ( 'fs' ) . readFile ;
148+ require ( 'fs' ) . unpatch = 123 ;
148149 before ( function ( ) {
149150 GitWrappedFs . patchInPlace ( ) ;
150151 } ) ;
@@ -177,8 +178,8 @@ describe('GitWrappedFs', function () {
177178
178179 after ( function ( ) {
179180 require ( 'fs' ) . unpatch ( ) ;
180- expect ( require ( 'fs' ) , 'not to have key' , 'unpatch' ) ;
181181 expect ( require ( 'fs' ) . readFile , 'to be' , originalReadFile ) ;
182+ expect ( require ( 'fs' ) . unpatch , 'to equal' , 123 ) ;
182183 } ) ;
183184 } ) ;
184185} ) ;
You can’t perform that action at this time.
0 commit comments