diff --git a/lib/utils.js b/lib/utils.js index fc73a5afb..a1c6433db 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -456,8 +456,12 @@ module.exports.isNotSet = function (obj) { return false; }; -module.exports.emptyFolder = async (directoryPath) => { - require('child_process').execSync(`rm -rf ${directoryPath}/*`); +module.exports.emptyFolder = (directoryPath) => { + // Do not throw on non-existent directory, since it may be created later + if (!fs.existsSync(directoryPath)) return; + for (const file of fs.readdirSync(directoryPath)) { + fs.rmSync(path.join(directoryPath, file), { recursive: true, force: true }); + } }; module.exports.printObjectProperties = (obj) => {