From a99da03c7791881accbd2caa7d6af5b41e35d120 Mon Sep 17 00:00:00 2001 From: Vallie Joseph Date: Mon, 12 Dec 2022 05:26:28 +0000 Subject: [PATCH] . --- packages/io/src/io.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/io/src/io.ts b/packages/io/src/io.ts index fe02bde1..e5c8254a 100644 --- a/packages/io/src/io.ts +++ b/packages/io/src/io.ts @@ -4,7 +4,7 @@ import * as path from 'path' import {promisify} from 'util' import * as ioUtil from './io-util' -const execFileSync = promisify(childProcess.execFileSync) +// const exec = promisify(childProcess.exec) // const fork = promisify(childProcess.fork) const execFile = promisify(childProcess.execFile) @@ -130,14 +130,20 @@ export async function rmRF(inputPath: string): Promise { try { const cmdPath = ioUtil.getCmdPath() if (await ioUtil.isDirectory(inputPath, true)) { - await execFileSync(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, { - env: {inputPath}, - windowsVerbatimArguments: true + await execFile(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, { + env: {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 { - await execFileSync(`${cmdPath} /s /c "del /f /a "%inputPath%""`, { - env: {inputPath}, - windowsVerbatimArguments: true + await execFile(`${cmdPath} /s /c "del /f /a "%inputPath%""`, { + env: {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 }) } } catch (err) {