fix: lint errors and deleting plugin error on windows

This commit is contained in:
viper151
2026-03-06 15:44:32 +01:00
parent 38accf6505
commit 24430fa343
10 changed files with 176 additions and 156 deletions

View File

@@ -326,13 +326,28 @@ export function updatePluginFromGit(name) {
});
}
export function uninstallPlugin(name) {
export async function uninstallPlugin(name) {
const pluginDir = getPluginDir(name);
if (!pluginDir) {
throw new Error(`Plugin "${name}" not found`);
}
fs.rmSync(pluginDir, { recursive: true, force: true });
// On Windows, file handles may be released slightly after process exit.
// Retry a few times with a short delay before giving up.
const MAX_RETRIES = 5;
const RETRY_DELAY_MS = 500;
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {
try {
fs.rmSync(pluginDir, { recursive: true, force: true });
break;
} catch (err) {
if (err.code === 'EBUSY' && attempt < MAX_RETRIES) {
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
} else {
throw err;
}
}
}
// Remove from config
const config = getPluginsConfig();