@taole/deploy-helper 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/offlinePkg.mjs +21 -2
- package/package.json +1 -1
package/lib/offlinePkg.mjs
CHANGED
|
@@ -13,8 +13,27 @@ function genArchive(outputPath, dir) {
|
|
|
13
13
|
const archive = archiver('zip', {
|
|
14
14
|
zlib: { level: 1 } // Sets the compression level.
|
|
15
15
|
});
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let settled = false;
|
|
17
|
+
const onError = (err) => {
|
|
18
|
+
if (settled) return;
|
|
19
|
+
settled = true;
|
|
20
|
+
try {
|
|
21
|
+
archive.abort();
|
|
22
|
+
} catch {
|
|
23
|
+
// ignore
|
|
24
|
+
}
|
|
25
|
+
output.destroy(err);
|
|
26
|
+
reject(err);
|
|
27
|
+
};
|
|
28
|
+
archive.on('error', onError);
|
|
29
|
+
output.on('error', onError);
|
|
30
|
+
// 必须等目标文件流关闭后再继续:仅 archive 'finish' 时缓冲区可能尚未完全刷盘,
|
|
31
|
+
// 后续 md5/上传会读到缺 END 中央目录的截断 zip(如 ADM-ZIP: No END header found)。
|
|
32
|
+
output.on('close', () => {
|
|
33
|
+
if (settled) return;
|
|
34
|
+
settled = true;
|
|
35
|
+
resolve();
|
|
36
|
+
});
|
|
18
37
|
archive.pipe(output);
|
|
19
38
|
archive.directory(dir, false);
|
|
20
39
|
archive.finalize();
|