MCPcopy Create free account
hub / github.com/code100x/mobile-magic / serializeFolder

Function serializeFolder

framework-serializer/index.ts:10–26  ·  view source on GitHub ↗
(folderPath: string)

Source from the content-addressed store, hash-verified

8let artifact = ""
9
10function serializeFolder(folderPath: string) {
11 const files = fs.readdirSync(folderPath)
12 files.forEach(file => {
13 const filePath = path.join(folderPath, file)
14 if (fs.statSync(filePath).isDirectory()) {
15 serializeFolder(filePath)
16 } else {
17 if (file.endsWith("package-lock.json") || file.endsWith(".ico") || file.endsWith(".ttf") || file.endsWith(".png") || file.endsWith(".jpg") || file.endsWith(".jpeg") || file.endsWith(".gif") || file.endsWith(".svg") || file.endsWith(".webp")) {
18 return;
19 }
20
21 artifact += `<file name="${file}">`
22 artifact += fs.readFileSync(filePath, {encoding: "utf-8"}).replaceAll("`", "\\`").replaceAll("$", "\\$")
23 artifact += `</file>`
24 }
25 })
26}
27
28serializeFolder(FOLDER_PATH)
29

Callers 1

index.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected