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