( zipFolderPath: string, content: ZipBuffer, zipName: string, )
| 11 | }; |
| 12 | |
| 13 | export const writeZipToDisk = ( |
| 14 | zipFolderPath: string, |
| 15 | content: ZipBuffer, |
| 16 | zipName: string, |
| 17 | ): void => { |
| 18 | if (!isNodeProcess()) { |
| 19 | throw new Error('ZipPublisher: writeZipToDisk is only available in NodeJS'); |
| 20 | } |
| 21 | |
| 22 | // eslint-disable-next-line @typescript-eslint/no-var-requires |
| 23 | // eslint-disable-next-line @typescript-eslint/no-require-imports |
| 24 | const fs = require('fs'); |
| 25 | // eslint-disable-next-line @typescript-eslint/no-var-requires |
| 26 | // eslint-disable-next-line @typescript-eslint/no-require-imports |
| 27 | const path = require('path'); |
| 28 | |
| 29 | if (!fs.existsSync(zipFolderPath)) { |
| 30 | fs.mkdirSync(zipFolderPath, { recursive: true }); |
| 31 | } |
| 32 | |
| 33 | const zipPath = path.join(zipFolderPath, `${zipName}.zip`); |
| 34 | |
| 35 | const writeStream = fs.createWriteStream(zipPath); |
| 36 | writeStream.write(content); |
| 37 | writeStream.end(); |
| 38 | }; |
| 39 | |
| 40 | export const generateProjectZip = async (project: ResultDir): Promise<ZipBuffer> => { |
| 41 | let zip = new JSZip(); |
no test coverage detected
searching dependent graphs…