-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostInstall.mjs
29 lines (25 loc) · 1.16 KB
/
postInstall.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env node
/*
* This script is used to remove the local tsyringe package when running inside the SPT-AKI project directory. This is
* necessary because the local tsyringe package will override the SPT-AKI tsyringe package, which will cause dependency
* injection to fail in a very confusing way, which will likely consume your afternoon and make you want to cry. :D
*/
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
const sptProjectFile = path.join(currentDirectory, "../../../src/Program.ts");
const isInsideSptProject = fs.existsSync(sptProjectFile);
if (isInsideSptProject) {
try {
fs.rmSync("node_modules/tsyringe", { recursive: true, force: true });
console.log("postInstall: Running inside SPT project directory. Removed local tsyringe package.");
process.exit(0);
} catch (err) {
console.error("postInstall: Failed to remove local tsyringe package:", err);
process.exit(1);
}
} else {
console.log("postInstall: Running outside of SPT project. No changes made.");
process.exit(0);
}