@@ -76,12 +76,17 @@ renameCssSelectors.process = (pathString, options, cb) => {
7676 async . eachSeries ( filesArray , ( filePath , callback ) => {
7777 rcs . replace . fileCss ( path . join ( options . cwd , filePath ) , options , ( err , data ) => {
7878 let joinedPath ;
79+ let shouldOverwrite = options . overwrite ;
7980
8081 if ( err ) callback ( err ) ;
8182
8283 joinedPath = path . join ( options . newPath , filePath ) ;
8384
84- rcs . helper . save ( joinedPath , data . data , ( err ) => {
85+ if ( ! options . overwrite ) {
86+ shouldOverwrite = joinedPath !== path . join ( options . cwd , filePath ) ;
87+ }
88+
89+ rcs . helper . save ( joinedPath , data . data , { overwrite : shouldOverwrite } , ( err ) => {
8590 if ( err ) callback ( err ) ;
8691
8792 callback ( ) ;
@@ -101,12 +106,17 @@ renameCssSelectors.process = (pathString, options, cb) => {
101106 async . each ( filesArray , ( filePath , callback ) => {
102107 rcs . replace . file ( path . join ( options . cwd , filePath ) , ( err , data ) => {
103108 let joinedPath ;
109+ let shouldOverwrite = options . overwrite ;
104110
105111 if ( err ) callback ( err ) ;
106112
107113 joinedPath = path . join ( options . newPath , filePath ) ;
108114
109- rcs . helper . save ( joinedPath , data . data , ( err ) => {
115+ if ( ! options . overwrite ) {
116+ shouldOverwrite = joinedPath !== path . join ( options . cwd , filePath ) ;
117+ }
118+
119+ rcs . helper . save ( joinedPath , data . data , { overwrite : shouldOverwrite } , ( err ) => {
110120 if ( err ) callback ( err ) ;
111121
112122 callback ( ) ;
0 commit comments