This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
electron-pkg.js
92 lines (70 loc) · 2.36 KB
/
electron-pkg.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env node
var _ = require('lodash');
var os = require('os');
var pkgjson = require('./package.json');
var path = require('path');
var sh = require('shelljs');
var appVersion = pkgjson.version
, electronPackager = 'electron-packager'
, electronVersion = '1.4.15'
, icon = 'www/img/icons/binary.icns';
var archs = ['ia32', 'x64'];
exports.build = function build(){
var inputPlatform = _.find(process.argv, (e) => { return e.indexOf('--platform') > -1;});
if(process.arch){
archs = [process.arch];
}
if (_.find(process.argv, (e) => { return e.indexOf('--all') > -1;})) {
// build for all platforms
var platforms = ['linux', 'darwin'];
// Only build for Windows when in Windows
if(process.platform === 'win32') platforms.push('win32');
platforms.forEach(function (plat) {
archs.forEach(function (arch) {
pack(plat, arch);
});
});
} else if (inputPlatform) {
archs.forEach(function (arch) {
var plat = inputPlatform;
pack(plat, arch);
});
} else {
// build for current platform only
pack(os.platform(), os.arch());
}
}
function pack (plat, arch) {
plat = plat.replace('--platform=', '');
var outputPath = './build/releases/' + plat + '/' + arch;
sh.exec('./node_modules/.bin/rimraf ' + outputPath);
var appName = pkgjson.name;
if(plat == 'linux') appName = appName.toLowerCase();
// there is no darwin ia32 electron
if (plat === 'darwin' && arch === 'ia32') return;
var cmds = [];
var location = '.';
cmds.push(electronPackager + ' '+location+' ' + appName +
' --platform=' + plat +
' --arch=' + arch +
' --electron-version=' + electronVersion +
' --app-version=' + appVersion +
' --icon=' + icon +
' --out=' + outputPath +
((plat == 'linux') ? '' : ' --prune') +
((plat === 'win32') ? ' --asar=true' : '') +
' --ignore="build|electron-packager|www|\.git|\.gitignore|gulpfile\.js|\.bowerrc' +
'|\.editorconfig|.*\.swp|.publish|bower\.json|config\.xml|crowdin\.yaml|electron-pkg\.json' +
'|hooks|ionic\.config\.json|node_modules|platforms|plugins|README\.md|resoucers|scss' +
'|resources|electron-pkg\.js"' +
' --overwrite');
for(var i in cmds){
console.log(cmds[i]);
if(process.platform == 'win32'){
sh.exec(cmds[i], {silent:false});
} else {
sh.exec(cmds[i]);
}
}
}
//exports.build();