MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / writeZipToDisk

Function writeZipToDisk

modules/code-generator/src/publisher/zip/utils.ts:13–38  ·  view source on GitHub ↗
(
  zipFolderPath: string,
  content: ZipBuffer,
  zipName: string,
)

Source from the content-addressed store, hash-verified

11};
12
13export 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
40export const generateProjectZip = async (project: ResultDir): Promise<ZipBuffer> => {
41 let zip = new JSZip();

Callers 1

publishFunction · 0.90

Calls 2

isNodeProcessFunction · 0.85
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…