Skip to content

Commit aa6ce3f

Browse files
committed
use native zip
1 parent 4abae60 commit aa6ce3f

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

build/bin.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { basename, join } from "node:path";
2-
import * as zip from "jsr:@zip-js/zip-js";
32
import { format, increment, parse } from "jsr:@std/semver";
43

54
const __dirname = new URL(".", import.meta.url).pathname;
@@ -25,24 +24,43 @@ async function compile(src: string, dest: string) {
2524

2625
const result = await cmd.output();
2726

28-
console.log(` > Exit Code: ${result.code}`);
27+
console.log(` > Compile Exit Code: ${result.code}`);
2928

3029
if (result.code !== 0) {
3130
return;
3231
}
3332

34-
// output
35-
const output = await Deno.open(`${dest}.zip`, {
36-
create: true,
37-
write: true,
38-
read: true,
33+
const zip = new Deno.Command(Deno.execPath(), {
34+
cwd: join(__dirname, "../dist"),
35+
args: [
36+
"zip",
37+
`${basename(dest)}.zip`,
38+
basename(dest),
39+
],
40+
stderr: "inherit",
41+
stdout: "inherit",
3942
});
4043

41-
const source = await Deno.open(dest, { read: true });
44+
const zipResult = await cmd.output();
45+
46+
console.log(` > Zip Exit Code: ${zipResult.code}`);
47+
48+
if (zipResult.code !== 0) {
49+
return;
50+
}
51+
52+
// // output
53+
// const output = await Deno.open(`${dest}.zip`, {
54+
// create: true,
55+
// write: true,
56+
// read: true,
57+
// });
58+
59+
// const source = await Deno.open(dest, { read: true });
4260

43-
const zipWriter = new zip.ZipWriter(output.writable);
44-
await zipWriter.add(basename(dest), source.readable);
45-
await zipWriter.close();
61+
// const zipWriter = new zip.ZipWriter(output.writable);
62+
// await zipWriter.add(basename(dest), source.readable);
63+
// await zipWriter.close();
4664

4765
await Deno.remove(dest);
4866
}

0 commit comments

Comments
 (0)