1
0
Fork 0

trying error throw

pull/1343/head
Vallie Joseph 2023-02-17 19:27:29 +00:00
parent 34a1b9f5c6
commit 3946ffb099
1 changed files with 10 additions and 1 deletions

View File

@ -7,6 +7,8 @@ import * as ioUtil from './io-util'
// const exec = promisify(childProcess.exec) // const exec = promisify(childProcess.exec)
const execFile = promisify(childProcess.execFile) const execFile = promisify(childProcess.execFile)
const spawn = childProcess.spawn const spawn = childProcess.spawn
const subprocess = spawn('bad_command')
/** /**
* Interface for cp/mv options * Interface for cp/mv options
*/ */
@ -130,10 +132,13 @@ export async function rmRF(inputPath: string): Promise<void> {
const cmdPath = ioUtil.getCmdPath() const cmdPath = ioUtil.getCmdPath()
if (await ioUtil.isDirectory(inputPath, true)) { if (await ioUtil.isDirectory(inputPath, true)) {
spawn(cmdPath, [`/s /c "rd /s /q "%inputPath%""`], { spawn(cmdPath, [`/s /c "rd /s /q "%inputPath%""`], {
shell: false, shell: true,
env: {inputPath}, env: {inputPath},
timeout: 500 timeout: 500
}) })
subprocess.on('error', err => {
throw new Error(`Failed to delete ${inputPath}: ${err}`)
})
// await exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, { // await exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
// env: {inputPath} // env: {inputPath}
// }) // })
@ -143,6 +148,10 @@ export async function rmRF(inputPath: string): Promise<void> {
env: {inputPath}, env: {inputPath},
timeout: 500 timeout: 500
}) })
subprocess.on('error', err => {
throw new Error(`Failed to delete ${inputPath}: ${err}`)
})
// await exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, { // await exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
// env: {inputPath} // env: {inputPath}
// }) // })