File tree 1 file changed +9
-12
lines changed
packages/react-scripts/scripts
1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -190,23 +190,20 @@ module.exports = function(
190
190
}
191
191
}
192
192
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
196
202
fs . moveSync (
197
203
path . join ( appPath , 'gitignore' ) ,
198
204
path . join ( appPath , '.gitignore' ) ,
199
205
[ ]
200
206
) ;
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
- }
210
207
}
211
208
212
209
let command ;
You can’t perform that action at this time.
0 commit comments