Skip to content

Commit bc10141

Browse files
committed
rename patch.js to main.js
1 parent 6c4634b commit bc10141

File tree

13 files changed

+15
-15
lines changed

13 files changed

+15
-15
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ SheltUpdate also supports including multiple branches in updates by separating t
6161
# Adding a branch
6262
SheltUpdate branches patch `discord_desktop_core` with files stored in `branches/<branch category>/<branch name>/`.
6363

64-
Branches must have a `patch.js` file to handle their injection in their branch directory, which is prepended to Discord's base `index.js` of the module.
64+
Branches must have a `main.js` file to handle their injection in their branch directory, which is prepended to Discord's base `index.js` of the module.
6565

6666
They must have a `meta.js` file that exports a `name` and `description`, and can optionally export a `setup` function,
6767
which may be asynchronous and will be periodically run. Use this to download other branch files you need.
@@ -76,7 +76,7 @@ sheltupdate will not automatically pick up and inject anything into the renderer
7676
in your preload.
7777

7878
```javascript
79-
// patch.js
79+
// main.js
8080
require('mod.js')
8181
```
8282

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/apiV1/moduleDownload/patchModule.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default withLogSection("module patcher", async (c, cacheDir, cacheFinalFi
4040
cpSync(cacheDir, cacheExtractDir, { recursive: true });
4141
}
4242

43-
writeFileSync(join(cacheExtractDir, "index.js"), dcMain.replace("// __BRANCHES_MAIN__", branch.patch));
43+
writeFileSync(join(cacheExtractDir, "index.js"), dcMain.replace("// __BRANCHES_MAIN__", branch.main));
4444
writeFileSync(join(cacheExtractDir, "preload.js"), dcPreload.replace("// __BRANCHES_PRELOAD__", branch.preload));
4545
writeFileSync(join(cacheExtractDir, "branches.json"), JSON.stringify(getSingleBranchMetas(), null, 4));
4646

src/apiV2/patchModule.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const patch = withLogSection("module patcher", async (m, branchName) => {
8383

8484
let deltaManifest = JSON.parse(readFileSync(join(eDir, "delta_manifest.json"), "utf8"));
8585

86-
const moddedIndex = dcMain.replace("// __BRANCHES_MAIN__", branch.patch);
86+
const moddedIndex = dcMain.replace("// __BRANCHES_MAIN__", branch.main);
8787
writeFileSync(join(filesDir, "index.js"), moddedIndex);
8888
deltaManifest.files["index.js"] = { New: { Sha256: sha256(moddedIndex) } };
8989

src/common/branchesLoader.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const init = withLogSection("branch finder", async () => {
7777

7878
let files = glob.sync(`${d}/*`);
7979

80-
let patch = "";
80+
let main = "";
8181
let preload = "";
8282
let displayName = name;
8383
let description = "";
@@ -88,13 +88,13 @@ const init = withLogSection("branch finder", async () => {
8888
const f = files[i];
8989
const filename = f.split("/").pop();
9090

91-
if (filename === "patch.js") {
92-
const patchSrc = readFileSync(f, "utf8").split("\n").join("\n\t\t");
93-
patch = `// Branch: ${displayName}\n\ttry {\n\t\t${patchSrc}\n\t} catch(e) { console.error("[sheltupdate] Main error (${displayName}):", e) }\n`;
91+
if (filename === "main.js") {
92+
const mainSrc = readFileSync(f, "utf8").split("\n").join("\n\t\t");
93+
main = `// Branch: ${name}\n\ttry {\n\t\t${mainSrc}\n\t} catch(e) { console.error("[sheltupdate] Main error (${name}):", e) }\n`;
9494
files.splice(i--, 1);
9595
} else if (filename === "preload.js") {
9696
const preloadSrc = readFileSync(f, "utf8").split("\n").join("\n\t");
97-
preload = `// Branch: ${displayName}\ntry {\n\t${preloadSrc}\n} catch(e) { console.error("[sheltupdate] Preload error (${displayName}):", e) }\n`;
97+
preload = `// Branch: ${name}\ntry {\n\t${preloadSrc}\n} catch(e) { console.error("[sheltupdate] Preload error (${name}):", e) }\n`;
9898
files.splice(i--, 1);
9999
} else if (filename === "meta.js") {
100100
const metaMod = await import(pathToFileURL(f));
@@ -124,13 +124,13 @@ const init = withLogSection("branch finder", async () => {
124124
const allFiles = glob.sync(`${d}/**/*.*`);
125125
const fileHashes = allFiles.map((f) => sha256(readFileSync(f)));
126126

127-
const version = parseInt(sha256(fileHashes.join(" ") + patch + preload + dcVersion).substring(0, 2), 16);
128-
const internalFiles = ["patch.js", "preload.js", "meta.js"];
127+
const version = parseInt(sha256(fileHashes.join(" ") + main + preload + dcVersion).substring(0, 2), 16);
128+
const internalFiles = ["main.js", "preload.js", "meta.js"];
129129

130130
branches[name] = {
131131
files: allFiles.filter((f) => !internalFiles.includes(basename(f))),
132132
cacheDirs: [cacheDir],
133-
patch,
133+
main,
134134
preload,
135135
version,
136136
type,
@@ -207,8 +207,8 @@ const init = withLogSection("branch finder", async () => {
207207
get cacheDirs() {
208208
return bs.flatMap((b) => b.cacheDirs);
209209
},
210-
patch: bs
211-
.map((x) => x.patch)
210+
main: bs
211+
.map((x) => x.main)
212212
.filter((p) => p)
213213
.join("\n\t"),
214214
preload: bs
@@ -271,7 +271,7 @@ const runBranchSetups = async () => {
271271

272272
const fileHashes = allFiles.map((f) => sha256(readFileSync(f)));
273273
branches[b].version = parseInt(
274-
sha256(fileHashes.join(" ") + branches[b].patch + branches[b].preload + dcVersion).substring(0, 2),
274+
sha256(fileHashes.join(" ") + branches[b].main + branches[b].preload + dcVersion).substring(0, 2),
275275
16,
276276
);
277277

0 commit comments

Comments
 (0)