-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
95 lines (83 loc) · 2.88 KB
/
gulpfile.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
93
94
95
const gulp = require('gulp')
const inno = require('gulp-inno')
const rename = require("gulp-rename")
const replace = require('gulp-replace')
const bom = require('gulp-bom')
const exec = require('child_process').exec
const config = require('./app/package.json')
// var argv = process.argv.slice(2)
// console.log('argv:' + argv)
gulp.task('env', function(){
gulp
.src('./config/' + process.env.NODE_ENV + '.js')
.pipe(rename('env.js'))
.pipe(gulp.dest('./app'))
})
gulp.task('dev', ['env'], function(cb){
exec('electron app', function(err) {
if (err) return cb(err)
cb()
})
})
gulp.task('mac', ['env'], function(cb){
exec('electron-packager ./app client --platform darwin --arch x64 --out dist/ --icon ./build/favicon.icns --overwrite --download.mirror https://npm.taobao.org/mirrors/electron/ --asar', function(err) {
if (err) return cb(err)
cb()
})
})
gulp.task('pack64', ['env'], function(cb){
exec('electron-packager ./app client --platform=win32 --arch=x64 --out=dist/ --icon=./build/favicon.ico --overwrite --download.mirror=https://npm.taobao.org/mirrors/electron/ --asar', function(err) {
if (err) return cb(err)
gulp
.src('./build/setup-win.iss')
.pipe(bom())
.pipe(replace('${version}', config.version))
.pipe(replace('${sourcePath}', 'client-win32-x64'))
.pipe(replace('${outputName}', 'client-win64-' + config.version + '-' + getShortName(process.env.NODE_ENV)))
.pipe(rename('client-win64-' + process.env.NODE_ENV + '.iss'))
.pipe(gulp.dest('./dist'))
.on('end', function(){
// console.log('pack win64 complete.')
cb()
})
})
})
gulp.task('build64', ['pack64'], function(){
gulp
.src('./dist/client-win64-' + process.env.NODE_ENV + '.iss')
.pipe(inno())
})
gulp.task('pack32', ['env'], function(cb){
exec('electron-packager ./app client --platform=win32 --arch=ia32 --out=dist/ --icon=./build/favicon.ico --overwrite --download.mirror=https://npm.taobao.org/mirrors/electron/ --asar', function(err) {
if (err) return cb(err)
gulp
.src('./build/setup-win.iss')
.pipe(bom())
.pipe(replace('${version}', config.version))
.pipe(replace('${sourcePath}', 'client-win32-ia32'))
.pipe(replace('${outputName}', 'client-win32-' + config.version + '-' + getShortName(process.env.NODE_ENV)))
.pipe(rename('client-win32-' + process.env.NODE_ENV + '.iss'))
.pipe(gulp.dest('./dist'))
.on('end', function(){
// console.log('pack win32 complete.')
cb()
})
})
})
gulp.task('build32', ['pack32'], function(){
gulp
.src('./dist/client-win32-' + process.env.NODE_ENV + '.iss')
.pipe(inno())
})
gulp.task('default', ['build64'])
function getShortName (env) {
switch (env) {
case 'development':
return 'dev'
case 'simulation':
return 'simu'
case 'production':
return 'prod'
}
return env
}