forked from Jelmerro/Vieb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
63 lines (60 loc) · 1.94 KB
/
build.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* Vieb - Vim Inspired Electron Browser
* Copyright (C) 2019-2021 Jelmer van Arnhem
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
"use strict"
const builder = require("electron-builder")
const rimraf = require("rimraf").sync
const archiver = require("archiver")
const {readFileSync, statSync, createWriteStream} = require("fs")
const {version} = JSON.parse(readFileSync("package.json").toString())
const builds = {}
const isDir = loc => {
try {
return statSync(loc).isDirectory()
} catch {
return false
}
}
rimraf("dist/")
process.argv.slice(1).forEach(a => {
if (a === "--linux") {
builds.linux = []
}
if (a === "--win") {
builds.win = []
}
if (a === "--mac") {
builds.mac = []
}
})
builder.build(builds).then(e => {
rimraf("dist/Vieb-*-mac.zip")
for (const os of ["mac", "mac-arm64"]) {
if (isDir(`dist/${os}/Vieb.app/`)) {
const zip = createWriteStream(`dist/Vieb-${version}-${os}.zip`)
const archive = archiver("zip", {"zlib": {"level": 9}})
archive.pipe(zip)
archive.directory(`dist/${os}/Vieb.app/`, "Vieb.app")
archive.file("README.md", {"name": "README.md"})
archive.file("LICENSE", {"name": "LICENSE"})
archive.finalize()
}
}
console.info(e)
}).catch(e => {
console.error(e)
})