@@ -68,6 +68,15 @@ describe('Replace in file', () => {
6868 } ) ) . to . eventually . be . rejectedWith ( Error ) ;
6969 } ) ;
7070
71+ it ( 'should throw an error when invalid `glob` config defined' , ( ) => {
72+ return expect ( replace ( {
73+ files : 'test1' ,
74+ from : / r e \s p l a c e / g,
75+ to : 'test' ,
76+ glob : 'invalid' ,
77+ } ) ) . to . eventually . be . rejectedWith ( Error ) ;
78+ } ) ;
79+
7180 it ( 'should replace contents in a single file with regex' , done => {
7281 replace ( {
7382 files : 'test1' ,
@@ -89,7 +98,7 @@ describe('Replace in file', () => {
8998 expect ( file ) . to . equal ( 'test1' ) ;
9099 return / r e \s p l a c e / g;
91100 } ,
92- to : 'b'
101+ to : 'b' ,
93102 } ) . then ( ( ) => {
94103 const test1 = fs . readFileSync ( 'test1' , 'utf8' ) ;
95104 const test2 = fs . readFileSync ( 'test2' , 'utf8' ) ;
@@ -344,6 +353,35 @@ describe('Replace in file', () => {
344353 done ( ) ;
345354 } ) ;
346355 } ) ;
356+
357+ it ( 'should accept glob configuration' , done => {
358+ replace ( {
359+ files : 'test1' ,
360+ from : / r e \s p l a c e / g,
361+ to : 'b' ,
362+ allowEmptyPaths : true ,
363+ glob : {
364+ ignore : [ 'test1' ] ,
365+ } ,
366+ } ) . then ( ( ) => {
367+ const test1 = fs . readFileSync ( 'test1' , 'utf8' ) ;
368+ expect ( test1 ) . to . equal ( 'a re place c' ) ;
369+ done ( ) ;
370+ } ) ;
371+ } ) ;
372+
373+ it ( 'should ignore empty glob configuration' , done => {
374+ replace ( {
375+ files : 'test1' ,
376+ from : / r e \s p l a c e / g,
377+ to : 'b' ,
378+ glob : null ,
379+ } ) . then ( ( ) => {
380+ const test1 = fs . readFileSync ( 'test1' , 'utf8' ) ;
381+ expect ( test1 ) . to . equal ( 'a b c' ) ;
382+ done ( ) ;
383+ } ) ;
384+ } ) ;
347385 } ) ;
348386
349387 /**
@@ -416,7 +454,7 @@ describe('Replace in file', () => {
416454 expect ( file ) . to . equal ( 'test1' ) ;
417455 return / r e \s p l a c e / g;
418456 } ,
419- to : 'b'
457+ to : 'b' ,
420458 } , ( ) => {
421459 const test1 = fs . readFileSync ( 'test1' , 'utf8' ) ;
422460 const test2 = fs . readFileSync ( 'test2' , 'utf8' ) ;
@@ -749,7 +787,7 @@ describe('Replace in file', () => {
749787 expect ( file ) . to . equal ( 'test1' ) ;
750788 return / r e \s p l a c e / g;
751789 } ,
752- to : 'b'
790+ to : 'b' ,
753791 } ) ;
754792 const test1 = fs . readFileSync ( 'test1' , 'utf8' ) ;
755793 const test2 = fs . readFileSync ( 'test2' , 'utf8' ) ;
0 commit comments