1
0
Fork 0
pull/1259/head
Vallie Joseph 2022-12-12 05:26:28 +00:00
parent e0023baa89
commit a99da03c77
1 changed files with 13 additions and 7 deletions

View File

@ -4,7 +4,7 @@ import * as path from 'path'
import {promisify} from 'util' import {promisify} from 'util'
import * as ioUtil from './io-util' import * as ioUtil from './io-util'
const execFileSync = promisify(childProcess.execFileSync) // const exec = promisify(childProcess.exec)
// const fork = promisify(childProcess.fork) // const fork = promisify(childProcess.fork)
const execFile = promisify(childProcess.execFile) const execFile = promisify(childProcess.execFile)
@ -130,14 +130,20 @@ export async function rmRF(inputPath: string): Promise<void> {
try { try {
const cmdPath = ioUtil.getCmdPath() const cmdPath = ioUtil.getCmdPath()
if (await ioUtil.isDirectory(inputPath, true)) { if (await ioUtil.isDirectory(inputPath, true)) {
await execFileSync(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, { await execFile(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
env: {inputPath}, env: {inputPath}
windowsVerbatimArguments: true }).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 { } else {
await execFileSync(`${cmdPath} /s /c "del /f /a "%inputPath%""`, { await execFile(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
env: {inputPath}, env: {inputPath}
windowsVerbatimArguments: true }).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) { } catch (err) {