MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / addDir

Function addDir

scripts/pack.js:114–132  ·  view source on GitHub ↗
(zip, localDir, toDir, filters)

Source from the content-addressed store, hash-verified

112const firefox = new ZipWriter({ outputAs: "uint8array" });
113
114async function addDir(zip, localDir, toDir, filters) {
115 const sub = async (localDir, toDir) => {
116 const files = await fs.readdir(localDir);
117 for (const file of files) {
118 if (filters?.includes(file)) {
119 continue;
120 }
121 const localPath = `${localDir}/${file}`;
122 const toPath = `${toDir}${file}`;
123 const stats = await fs.stat(localPath);
124 if (stats.isDirectory()) {
125 await sub(localPath, `${toPath}/`);
126 } else {
127 await addZipFile(zip, toPath, await fs.readFile(localPath));
128 }
129 }
130 };
131 await sub(localDir, toDir);
132}
133
134await addZipFile(chrome, "manifest.json", JSON.stringify(chromeManifest));
135await addZipFile(firefox, "manifest.json", JSON.stringify(firefoxManifest));

Callers 1

pack.jsFile · 0.85

Calls 1

subFunction · 0.85

Tested by

no test coverage detected