From 665b756702a1a77bc33ffb89fc17c2c64ab26d6b Mon Sep 17 00:00:00 2001 From: Cory Miller <13227161+cory-miller@users.noreply.github.com> Date: Thu, 23 Feb 2023 17:26:31 +0000 Subject: [PATCH] try rmSync --- packages/io/__tests__/io.test.ts | 24 ++++++++++++------------ packages/io/src/io-util.ts | 4 ++++ packages/io/src/io.ts | 4 ++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/io/__tests__/io.test.ts b/packages/io/__tests__/io.test.ts index 4daefb1c..bfeefab4 100644 --- a/packages/io/__tests__/io.test.ts +++ b/packages/io/__tests__/io.test.ts @@ -345,18 +345,18 @@ describe('rmRF', () => { const fd = await fs.open(filePath, 'r') - // can't remove folder with locked file on windows - if (ioUtil.IS_WINDOWS) { - try { - // additionally, can't stat an open file on Windows without getting EPERM - await io.rmRF(testPath) - } catch (err) { - expect(err.code).toBe('EPERM') - } - } else { - await io.rmRF(testPath) - await assertNotExists(testPath) - } + // // can't remove folder with locked file on windows + // if (ioUtil.IS_WINDOWS) { + // try { + // // additionally, can't stat an open file on Windows without getting EPERM + // await io.rmRF(testPath) + // } catch (err) { + // expect(err.code).toBe('EPERM') + // } + // } else { + await io.rmRF(testPath) + await assertNotExists(testPath) + // } await fd.close() await io.rmRF(testPath) diff --git a/packages/io/src/io-util.ts b/packages/io/src/io-util.ts index 19066319..68a4ac0a 100644 --- a/packages/io/src/io-util.ts +++ b/packages/io/src/io-util.ts @@ -17,6 +17,10 @@ export const { unlink } = fs.promises +export const { + rmSync +} = fs + export const IS_WINDOWS = process.platform === 'win32' export async function exists(fsPath: string): Promise { diff --git a/packages/io/src/io.ts b/packages/io/src/io.ts index fe1cfbdd..077c973c 100644 --- a/packages/io/src/io.ts +++ b/packages/io/src/io.ts @@ -120,11 +120,11 @@ export async function rmRF(inputPath: string): Promise { } } - await ioUtil.rm(inputPath, { + ioUtil.rmSync(inputPath, { force: true, maxRetries: 3, recursive: true, - retryDelay: 200 + retryDelay: 300 }) }