MCPcopy Create free account
hub / github.com/MCSManager/MCSManager / deleteMod

Method deleteMod

daemon/src/service/mod_service.ts:352–378  ·  view source on GitHub ↗
(instanceUuid: string, fileName: string)

Source from the content-addressed store, hash-verified

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,

Callers 1

Instance_router.tsFile · 0.80

Calls 5

checkPathMethod · 0.95
toAbsolutePathMethod · 0.95
resolveMCDRServerRootFunction · 0.90
absoluteCwdPathMethod · 0.80
getInstanceMethod · 0.45

Tested by

no test coverage detected