-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.ts
37 lines (28 loc) · 906 Bytes
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import __ from "https://deno.land/x/dirname/mod.ts";
import * as path from "https://deno.land/[email protected]/path/mod.ts";
import { JSZip } from "https://deno.land/x/jszip/mod.ts";
import {
emptyDirSync,
ensureDirSync,
} from "https://deno.land/[email protected]/fs/mod.ts";
const { __dirname } = __(import.meta);
const targets = [
"Config.plist",
"icon.png",
"open.applescript",
];
const cwd = __dirname;
const packageName = path.basename(cwd);
const extName = packageName + ".popclipext";
const dst = path.resolve(cwd, extName);
ensureDirSync(extName);
emptyDirSync(extName);
const zip = new JSZip();
const pkgFolder = zip.folder(extName);
for (const target of targets) {
const srcFile = path.resolve(cwd, target);
const content = Deno.readFileSync(srcFile);
pkgFolder.addFile(target, content);
}
await zip.writeZip(path.resolve(cwd, packageName + ".popclipextz"));
Deno.removeSync(dst);