| 8 | let artifact = "" |
| 9 | |
| 10 | function 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 | |
| 28 | serializeFolder(FOLDER_PATH) |
| 29 | |