@@ -290,24 +290,24 @@ function rmkidsSync (p, options) {
290
290
assert ( options )
291
291
options . readdirSync ( p ) . forEach ( f => rimrafSync ( path . join ( p , f ) , options ) )
292
292
293
- // We only end up here once we got ENOTEMPTY at least once, and
294
- // at this point, we are guaranteed to have removed all the kids.
295
- // So , we know that it won't be ENOENT or ENOTDIR or anything else .
296
- // try really hard to delete stuff on windows, because it has a
297
- // PROFOUNDLY annoying habit of not closing handles promptly when
298
- // files are deleted, resulting in spurious ENOTEMPTY errors.
299
- const retries = isWindows ? 100 : 1
300
- let i = 0
301
- do {
302
- let threw = true
303
- try {
304
- const ret = options . rmdirSync ( p , options )
305
- threw = false
306
- return ret
307
- } finally {
308
- if ( ++ i < retries && threw ) continue // eslint-disable-line
309
- }
310
- } while ( true )
293
+ if ( isWindows ) {
294
+ // We only end up here once we got ENOTEMPTY at least once, and
295
+ // at this point , we are guaranteed to have removed all the kids .
296
+ // So, we know that it won't be ENOENT or ENOTDIR or anything else.
297
+ // try really hard to delete stuff on windows, because it has a
298
+ // PROFOUNDLY annoying habit of not closing handles promptly when
299
+ // files are deleted, resulting in spurious ENOTEMPTY errors.
300
+ const startTime = Date . now ( )
301
+ do {
302
+ try {
303
+ const ret = options . rmdirSync ( p , options )
304
+ return ret
305
+ } catch ( er ) { }
306
+ } while ( Date . now ( ) - startTime < 500 ) // give up after 500ms
307
+ } else {
308
+ const ret = options . rmdirSync ( p , options )
309
+ return ret
310
+ }
311
311
}
312
312
313
313
module . exports = rimraf
0 commit comments