Skip to content

Commit

Permalink
fix: clean & check mod only if forge enabled
Browse files Browse the repository at this point in the history
Former-commit-id: 9b30dc9
  • Loading branch information
ci010 committed Jul 15, 2019
1 parent 822d625 commit 440725f
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/main/store/modules/launch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MinecraftFolder, Launcher } from 'ts-minecraft';
import paths from 'path';
import paths, { join } from 'path';
import { ipcMain } from 'electron';
import { existsSync, mkdirSync, fstat, promises } from 'fs';

/**
* @param {{ message: string; type: string; }} e
Expand Down Expand Up @@ -84,14 +85,23 @@ const mod = {
console.error('Cannot deploy resource packs');
console.error(e);
}
try {
await context.dispatch('deployResources', {
resources: mods,
minecraft: option.gamePath,
});
} catch (e) {
console.error('Cannot deploy mods');
console.error(e);

if (profile.forge.version || profile.liteloader.version) {
try {
const modsDir = join(option.gamePath, 'mods');
if (!existsSync(modsDir)) {
mkdirSync(modsDir);
}
const files = await promises.readdir(modsDir);
await Promise.all(files.map(file => promises.unlink(join(modsDir, file))));
await context.dispatch('deployResources', {
resources: mods,
minecraft: option.gamePath,
});
} catch (e) {
console.error('Cannot deploy mods');
console.error(e);
}
}

console.log(JSON.stringify(option));
Expand Down

0 comments on commit 440725f

Please sign in to comment.