File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed
packages/react-scripts/scripts Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -190,23 +190,20 @@ module.exports = function(
190190 }
191191 }
192192
193- // Rename gitignore after the fact to prevent npm from renaming it to .npmignore
194- // See: https://github.com/npm/npm/issues/1862
195- try {
193+ const gitignoreExists = fs . existsSync ( path . join ( appPath , '.gitignore' ) ) ;
194+ if ( gitignoreExists ) {
195+ // Append if there's already a `.gitignore` file there
196+ const data = fs . readFileSync ( path . join ( appPath , 'gitignore' ) ) ;
197+ fs . appendFileSync ( path . join ( appPath , '.gitignore' ) , data ) ;
198+ fs . unlinkSync ( path . join ( appPath , 'gitignore' ) ) ;
199+ } else {
200+ // Rename gitignore after the fact to prevent npm from renaming it to .npmignore
201+ // See: https://github.com/npm/npm/issues/1862
196202 fs . moveSync (
197203 path . join ( appPath , 'gitignore' ) ,
198204 path . join ( appPath , '.gitignore' ) ,
199205 [ ]
200206 ) ;
201- } catch ( err ) {
202- // Append if there's already a `.gitignore` file there
203- if ( err . code === 'EEXIST' ) {
204- const data = fs . readFileSync ( path . join ( appPath , 'gitignore' ) ) ;
205- fs . appendFileSync ( path . join ( appPath , '.gitignore' ) , data ) ;
206- fs . unlinkSync ( path . join ( appPath , 'gitignore' ) ) ;
207- } else {
208- throw err ;
209- }
210207 }
211208
212209 let command ;
You can’t perform that action at this time.
0 commit comments