🐛 Fix crash if engine directory does not exist

This commit is contained in:
trickypr 2022-11-17 11:31:53 +11:00
parent c8484ec8d8
commit 2fc60b26eb

View file

@ -127,8 +127,8 @@ export async function downloadInternals({ version, force }: { version: string, f
}
// If the engine directory is empty, we should delete it.
const engineIsEmpty = await readdir(ENGINE_DIR).then((files) => files.length === 0)
if (existsSync(ENGINE_DIR) && engineIsEmpty) {
const engineIsEmpty = existsSync(ENGINE_DIR) && await readdir(ENGINE_DIR).then((files) => files.length === 0)
if (engineIsEmpty) {
log.info("'engine/' is empty, it...")
rmSync(ENGINE_DIR, { recursive: true })
}