mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-22 13:39:09 +08:00
try awaiting spawn on windows
This commit is contained in:
parent
d2b7d85e7c
commit
a730b5ca5f
@ -128,15 +128,28 @@ export async function rmRF(inputPath: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const cmdPath = ioUtil.getCmdPath()
|
const cmdPath = ioUtil.getCmdPath()
|
||||||
if (await ioUtil.isDirectory(inputPath, true)) {
|
|
||||||
await exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
|
const p = new Promise(async (resolve, reject) => {
|
||||||
env: {inputPath}
|
setTimeout(() => {
|
||||||
|
resolve("timeout")
|
||||||
|
}, 500)
|
||||||
|
|
||||||
|
let result = null;
|
||||||
|
if (await ioUtil.isDirectory(inputPath, true)) {
|
||||||
|
result = childProcess.spawn(cmdPath, ['/s', '/c', '"rd /s /q "%inputPath%""'], {
|
||||||
|
env: {inputPath}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
result = childProcess.spawn('cmdPath', ['/s', '/c', '"del /f /a "%inputPath%""'], {
|
||||||
|
env: {inputPath}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
result.on('close', (code) => {
|
||||||
|
resolve(code)
|
||||||
})
|
})
|
||||||
} else {
|
})
|
||||||
await exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
|
await p
|
||||||
env: {inputPath}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// if you try to delete a file that doesn't exist, desired result is achieved
|
// if you try to delete a file that doesn't exist, desired result is achieved
|
||||||
// other errors are valid
|
// other errors are valid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user