Skip to content

Commit 83f5db3

Browse files
committed
Add GodotML v7 support to GodotMLInstaller
The mod loader package now contains an extra folder which needs to be copied when the mod loader is installed.
1 parent 18946cd commit 83f5db3

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/installers/GodotMLInstaller.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
1-
import { InstallArgs, PackageInstaller } from "./PackageInstaller";
2-
import path from "path";
3-
import FsProvider from "../providers/generic/file/FsProvider";
1+
import path from 'path';
2+
3+
import { InstallArgs, PackageInstaller } from './PackageInstaller';
4+
import FileWriteError from '../model/errors/FileWriteError';
5+
import FsProvider from '../providers/generic/file/FsProvider';
6+
import FileUtils from '../utils/FileUtils';
7+
48

59
export class GodotMLInstaller implements PackageInstaller {
10+
// JSON_Schema_Validator present on v7.0.1+ only.
11+
private static readonly TRACKED = ['mod_loader', 'JSON_Schema_Validator']
12+
613
/**
714
* Handles installation of GodotML
815
*/
916
async install(args: InstallArgs) {
1017
const { packagePath, profile } = args;
1118

12-
const copyFrom = path.join(packagePath, "addons", "mod_loader");
13-
const copyTo = profile.joinToProfilePath("addons", "mod_loader");
14-
const fs = FsProvider.instance;
19+
try {
20+
for (const fileOrFolder of GodotMLInstaller.TRACKED) {
21+
const copyFrom = path.join(packagePath, 'addons', fileOrFolder);
22+
23+
if (!await FsProvider.instance.exists(copyFrom)) {
24+
continue;
25+
}
1526

16-
if (await fs.exists(copyFrom)) {
17-
if (!await fs.exists(copyTo)) {
18-
await fs.mkdirs(copyTo);
27+
const copyTo = profile.joinToProfilePath('addons', fileOrFolder);
28+
await FileUtils.copyFileOrFolder(copyFrom, copyTo);
1929
}
20-
await fs.copyFolder(copyFrom, copyTo);
30+
} catch (e) {
31+
throw FileWriteError.fromThrownValue(e, 'Failed to install GodotML');
2132
}
2233
}
2334
}

0 commit comments

Comments
 (0)