forked from AgoraIO-Extensions/Electron-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
just-task.js
executable file
·105 lines (98 loc) · 2.97 KB
/
just-task.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
96
97
98
99
100
101
102
103
104
const { task, option, logger, argv, series, condition } = require('just-task');
const path = require('path')
const build = require('./scripts/build')
const download = require('./scripts/download')
const switcharch = require('./scripts/switch_arch')
const synclib = require('./scripts/synclib')
const cleanup = require('./scripts/cleanup')
const {getArgvFromNpmEnv, getArgvFromPkgJson} = require('./scripts/npm_argv')
option('electron_version', {default: '5.0.8'});
option('runtime', {default: 'electron', choices: ['electron', 'node']});
option('platform', {default: process.platform, choices: ['darwin', 'win32']});
// option('packageVersion');
option('debug', {default: false, boolean: true});
option('silent', {default: false, boolean: true});
option('msvs_version', {default: '2015'});
option('liburl_win', {default: ''});
option('liburl_mac', {default: ''});
const packageVersion = require('./package.json').version;
task('switch:arch', () => {
return switcharch({
arch: argv().arch,
// platform: 'win32',
})
})
task('sync:lib', () => {
const config = Object.assign({}, getArgvFromPkgJson(), getArgvFromNpmEnv() )
return synclib({
platform: argv().platform,
// platform: 'win32',
arch: argv().arch,
libUrl: {
win: argv().liburl_win || config.libUrl.win,
mac: argv().liburl_mac || config.libUrl.mac,
win64: argv().liburl_win64 || config.libUrl.win64
}
})
})
// npm run build:electron --
task('build:electron', () => {
cleanup(path.join(__dirname, "./build")).then(_ => {
build({
electronVersion: argv().electron_version,
runtime: argv().runtime,
platform: argv().platform,
packageVersion,
debug: argv().debug,
silent: argv().silent,
arch: argv().arch,
msvsVersion: argv().msvs_version,
distUrl: argv().dist_url
})
})
})
// npm run build:node --
task('build:node', () => {
build({
electronVersion: argv().electron_version,
runtime: 'node',
packageVersion,
platform: argv().platform,
debug: argv().debug,
silent: argv().silent,
msvsVersion: argv().msvs_version
})
})
// npm run download --
task('download', () => {
// work-around
const addonVersion = '2.9.0-rc.102-build.315'
cleanup(path.join(__dirname, "./build")).then(_ => {
cleanup(path.join(__dirname, './js')).then(_ => {
download({
electronVersion: argv().electron_version,
platform: argv().platform,
packageVersion: addonVersion,
arch: argv().arch
})
})
})
})
// trigger when run npm install
task('install', () => {
const config = Object.assign({}, getArgvFromNpmEnv(), getArgvFromPkgJson())
// work-around
const addonVersion = '2.9.0-rc.102-build.315'
if (config.prebuilt) {
download({
electronVersion: config.electronVersion,
platform: config.platform,
packageVersion: addonVersion,
arch: config.arch
})
} else {
build(Object.assign({}, config, {
packageVersion: addonVersion
}))
}
})