Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit b933750

Browse files
committed
修复 错误的zip命令使用格式
1 parent 11c2852 commit b933750

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/common/compress.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,14 @@ async function linuxUnzip(sourceZip: string, destDir: string) {
127127
}
128128

129129
// zip -r a.zip css css_v1 js
130+
// 此功能压缩的ZIP文件和文件所在目录必须在同一个目录下
130131
async function linuxZip(sourceZip: string, files: string[]) {
132+
if (!files || files.length == 0) return false;
131133
return new Promise((resolve, reject) => {
132-
let p = ["-r", sourceZip];
133-
p = p.concat(files);
134-
console.log("linuxZip:", p);
135-
const process = child_process.spawn("zip", p, {
136-
cwd: path.normalize(path.dirname(sourceZip))
134+
files = files.map((v) => path.normalize(path.basename(v)));
135+
console.log("linuxZip:", ["-r", sourceZip, ...files]);
136+
const process = child_process.spawn("zip", ["-r", sourceZip, ...files], {
137+
cwd: path.normalize(path.dirname(files[0]))
137138
});
138139
process.stdout.on("data", (data) => {
139140
console.log(data.toString("utf-8"));

0 commit comments

Comments
 (0)