MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / zip

Function zip

javascriptv3/example_code/libs/utils/util-fs.js:62–85  ·  view source on GitHub ↗
(inputPath)

Source from the content-addressed store, hash-verified

60 .map((dirent) => dirent.name);
61
62export const zip = (inputPath) =>
63 new Promise((resolve, reject) => {
64 try {
65 readdirSync(inputPath);
66 } catch (err) {
67 reject(
68 new Error(
69 `Cannot zip directory ${inputPath}. Directory doesn't exist.`,
70 ),
71 );
72 return;
73 }
74 const archive = archiver("zip");
75 logger.log(`Zipping ${inputPath}...`);
76
77 const output = createWriteStream(`${inputPath}.zip`);
78 output.on("close", handleZipEnd(resolve, `${inputPath}.zip`));
79
80 archive.pipe(output);
81 archive.on("error", reject);
82 archive.on("warning", handleZipWarning(resolve));
83 archive.directory(inputPath, false);
84 archive.finalize();
85 });

Calls 3

handleZipEndFunction · 0.85
handleZipWarningFunction · 0.85
logMethod · 0.45

Tested by 4

test_add_booksFunction · 0.68
test_get_reportFunction · 0.68