(instanceUuid: string, fileName: string)
| 350 | } |
| 351 | |
| 352 | public async deleteMod(instanceUuid: string, fileName: string): Promise<void> { |
| 353 | const instance = InstanceSubsystem.getInstance(instanceUuid)!; |
| 354 | const cwd = instance.absoluteCwdPath(); |
| 355 | const fileManager = new FileManager( |
| 356 | resolveMCDRServerRoot(instance.config.type, cwd) ?? cwd, |
| 357 | instance.config?.fileCode |
| 358 | ); |
| 359 | if (!fileManager.checkPath(fileName)) throw new Error("Invalid file name"); |
| 360 | const rootDir = fileManager.toAbsolutePath("."); |
| 361 | |
| 362 | const possibleDirs = ["mods", "plugins", "Mods", "Plugins"]; |
| 363 | let filePath = ""; |
| 364 | |
| 365 | for (const dirName of possibleDirs) { |
| 366 | const p = path.join(rootDir, dirName, fileName); |
| 367 | if (await fs.pathExists(p)) { |
| 368 | filePath = p; |
| 369 | break; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | if (!filePath) { |
| 374 | throw new Error("File not found"); |
| 375 | } |
| 376 | |
| 377 | await fs.remove(filePath); |
| 378 | } |
| 379 | |
| 380 | public async installMod( |
| 381 | instanceUuid: string, |
no test coverage detected