diff --git a/packages/io/src/io.ts b/packages/io/src/io.ts index 3d7a0f53..a7f65a9c 100644 --- a/packages/io/src/io.ts +++ b/packages/io/src/io.ts @@ -115,9 +115,6 @@ export async function mv( */ export async function rmRF(inputPath: string): Promise { if (ioUtil.IS_WINDOWS) { - // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another - // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del. - // Check for invalid characters // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file if (/[*"<>|]/.test(inputPath)) { @@ -125,45 +122,14 @@ export async function rmRF(inputPath: string): Promise { 'File path must not contain `*`, `"`, `<`, `>` or `|` on Windows' ) } - - try { - await ioUtil.rm(inputPath, { - force: true, - maxRetries: 3, - recursive: true, - retryDelay: 200 - }) - } 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 - } - - // // Shelling out fails to remove a symlink folder with missing source, this unlink catches that - // try { - // 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 - // } - } else { - let isDir = false - try { - isDir = await ioUtil.isDirectory(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 - return - } - - if (isDir) { - await execFile(`rm`, [`-rf`, `${inputPath}`]) - } else { - await ioUtil.unlink(inputPath) - } } + + await ioUtil.rm(inputPath, { + force: true, + maxRetries: 3, + recursive: true, + retryDelay: 200 + }) } /**