forked from CircuitCoder/Console-Lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack.js
67 lines (59 loc) · 1.58 KB
/
pack.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
64
65
66
67
const packager = require('electron-packager');
const process = require('process');
const path = require('path');
function pack(cb, silent) {
if(!silent) {
console.log(`Building package for ${process.platform} - ${process.arch}.`);
console.log('Please ensure that native dependecies are built using correct ABI version');
}
const opt = {
arch: process.arch,
platform: process.platform,
out: path.dirname(__dirname),
dir: path.dirname(__dirname),
prune: true,
ignore: [
/^\/server\/.*\.db($|\/)/,
/^\/server\/.*\.files($|\/)/,
/^\/Console Lite/,
/^\/Console-Lite-/,
], // Ignores databases, files and artifacts
icon: path.join(__dirname, '../images/icon'),
win32metadata: {
'requested-execution-level': 'requireAdministrator',
},
};
if(process.env.ELECTRON_MIRROR)
opt.download = {
mirror: process.env.ELECTRON_MIRROR,
};
packager(opt)
.then(paths => {
console.log(paths);
if(!silent)
console.log(`Package outputted to: ${paths}`);
if(cb) cb(null, paths);
})
.catch(err => {
if(!silent) {
console.error('Packager failed:');
console.error(err.stack);
}
if(cb) cb(err);
});
}
/* eslint-disable global-require */
if(require.main === module) {
const ora = require('ora');
const ind = ora('Packaging').start();
pack((err, paths) => {
if(err) {
ind.fail();
console.error(err.stack);
} else {
ind.text = `Package outputted to: ${paths}`;
ind.succeed();
}
}, true);
}
module.exports = pack;