update
This commit is contained in:
39
a1_pl_dpd_post/zip.js
Normal file
39
a1_pl_dpd_post/zip.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const fs = require("fs");
|
||||
const archiver = require("archiver");
|
||||
|
||||
// 创建一个输出流到指定的 zip 文件
|
||||
const output = fs.createWriteStream(__dirname + "/../../zip/a1_pl_dpd_post.zip"); // 这里可以更改为你想要的文件名
|
||||
const archive = archiver("zip", {
|
||||
zlib: { level: 9 }, // 设置压缩级别
|
||||
});
|
||||
|
||||
// 监听关闭事件,打印压缩完成信息
|
||||
output.on("close", function () {
|
||||
console.log(archive.pointer() + " total bytes");
|
||||
console.log(
|
||||
"archiver has been finalized and the output file descriptor has closed."
|
||||
);
|
||||
});
|
||||
|
||||
// 捕获警告
|
||||
archive.on("warning", function (err) {
|
||||
if (err.code === "ENOENT") {
|
||||
// log warning
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
// 捕获错误
|
||||
archive.on("error", function (err) {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// 将输出流管道到归档文件
|
||||
archive.pipe(output);
|
||||
|
||||
// 添加目录到归档文件
|
||||
archive.directory("dist/", false);
|
||||
|
||||
// 完成归档
|
||||
archive.finalize();
|
||||
Reference in New Issue
Block a user