MCPcopy Create free account
hub / github.com/Explosion-Scratch/firebuilder / handle

Function handle

modules/custom-js/index.js:10–49  ·  view source on GitHub ↗
({
  profilePath,
  modulesPath,
  options = {},
  appPath,
  enabled = [],
})

Source from the content-addressed store, hash-verified

8const exec = promisify(_exec);
9
10export default async function handle({
11 profilePath,
12 modulesPath,
13 options = {},
14 appPath,
15 enabled = [],
16}) {
17 const folder = resolve(mkdtempSync());
18 const sourcesFolder = resolve(mkdtempSync());
19 onExit(() => {
20 rmdirSync(folder, { recursive: true });
21 });
22 onExit(() => {
23 rmdirSync(sourcesFolder, { recursive: true });
24 });
25 await exec(
26 `git clone "https://github.com/MrOtherGuy/fx-autoconfig" ${JSON.stringify(
27 folder
28 )}`
29 );
30 const resources = resolve(appPath, "Contents", "Resources");
31 cpSync(join(folder, "program"), resources, { recursive: true });
32 cpSync(join(folder, "profile", "chrome"), resolve(profilePath, "chrome"), {
33 recursive: true,
34 });
35 const prefs = { ...readJSON(resolve(modulesPath, "index.json")), ...options };
36 for (let [url, details] of Object.entries(prefs.sources)) {
37 const dest = resolve(sourcesFolder, details.id || details.name);
38 await exec(`git clone ${JSON.stringify(url)} ${JSON.stringify(dest)}`);
39 for (let file of details.enabled) {
40 cpSync(
41 join(dest, file),
42 join(profilePath, "chrome", "JS", basename(file))
43 );
44 }
45 }
46 console.log({
47 folder,
48 });
49}

Callers

nothing calls this directly

Calls 2

onExitFunction · 0.85
readJSONFunction · 0.85

Tested by

no test coverage detected