diff --git a/scripts/build-portal-runtime.mjs b/scripts/build-portal-runtime.mjs index 0ea8ddb..d7cfa86 100755 --- a/scripts/build-portal-runtime.mjs +++ b/scripts/build-portal-runtime.mjs @@ -65,7 +65,13 @@ async function exists(targetPath) { } async function remove(targetPath) { - await fs.rm(targetPath, { recursive: true, force: true }); + if (!(await exists(targetPath))) return; + try { + await fs.rm(targetPath, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 }); + } catch (error) { + if (error?.code !== 'ENOTEMPTY' && error?.code !== 'EBUSY') throw error; + await run('rm', ['-rf', targetPath]); + } } async function copyDir(source, target) {