From 6a3c62d3a8e3eb7c697f908781c04b5fb6112448 Mon Sep 17 00:00:00 2001 From: Cory Miller <13227161+cory-miller@users.noreply.github.com> Date: Fri, 17 Feb 2023 20:37:22 +0000 Subject: [PATCH] try ignore eperm --- packages/io/__tests__/io.test.ts | 5 ----- packages/io/src/io.ts | 7 ++++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/io/__tests__/io.test.ts b/packages/io/__tests__/io.test.ts index e0208b1a..829e0dd9 100644 --- a/packages/io/__tests__/io.test.ts +++ b/packages/io/__tests__/io.test.ts @@ -193,7 +193,6 @@ describe('cp', () => { describe('mv', () => { beforeAll(async () => { - console.log('before') await io.rmRF(getTestTemp()) }) @@ -201,13 +200,9 @@ describe('mv', () => { const root = path.join(getTestTemp(), ' mv_with_no_flags') const sourceFile = path.join(root, ' mv_source') const targetFile = path.join(root, ' mv_target') - console.log('make') await io.mkdirP(root) - console.log('write') await fs.writeFile(sourceFile, 'test file content', {encoding: 'utf8'}) - console.log('move') await io.mv(sourceFile, targetFile) - console.log('read') expect(await fs.readFile(targetFile, {encoding: 'utf8'})).toBe( 'test file content' ) diff --git a/packages/io/src/io.ts b/packages/io/src/io.ts index 7f874035..a8c18d32 100644 --- a/packages/io/src/io.ts +++ b/packages/io/src/io.ts @@ -125,7 +125,7 @@ export async function rmRF(inputPath: string): Promise { 'File path must not contain `*`, `"`, `<`, `>` or `|` on Windows' ) } - console.log('a') + try { const cmdPath = ioUtil.getCmdPath() @@ -163,16 +163,17 @@ export async function rmRF(inputPath: string): Promise { // other errors are valid if (err.code !== 'ENOENT') throw err } - console.log('b') + // Shelling out fails to remove a symlink folder with missing source, this unlink catches that try { if (await ioUtil.exists(inputPath)) { + console.log('exists') await ioUtil.unlink(inputPath) } } catch (err) { // if you try to delete a file that doesn't exist, desired result is achieved // other errors are valid - if (err.code !== 'ENOENT') throw err + if (err.code !== 'ENOENT' || err.code !== 'EPERM') throw err } } else { let isDir = false