This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgulpfile.js
75 lines (70 loc) · 2.32 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
const shell = require('shelljs')
const path = require('path')
const gulp = require('gulp')
shell.config.throw = true // Throw on error
gulp.task('dev-watch-files', function (done) {
shell.rm('-rf', '_build')
shell.mkdir('_build')
shell.cp('src/tc-renderer/index.html', '_build/index.html')
shell.cp('src/package.json', '_build/package.json')
shell.exec(path.normalize(
'./node_modules/.bin/webpack --mode development --watch'
))
done()
})
gulp.task('dev-launch-electron', function (done) {
shell.exec(path.normalize(
'./node_modules/.bin/electron --enable-logging ./_build --dev-tools'
))
done()
})
gulp.task('build', function (done) {
shell.rm('-rf', '_dist')
shell.mkdir('-p', '_dist')
shell.rm('-rf', '_build')
shell.exec(path.normalize('./node_modules/.bin/webpack --mode production'))
shell.cp('src/tc-renderer/index.html', '_build/index.html')
shell.cp('src/package.json', '_build/package.json')
switch (process.platform) {
case 'win32':
console.log('\nAttempting to build Windows version.')
build('windows')
break
case 'linux':
console.log('\nAttempting to build Linux version.')
build('linux')
break
case 'darwin':
console.log('\nAttempting to build Mac version.')
build('mac')
break
}
shell.rm('-rf', 'dist')
done()
})
function build (platform) {
if (platform === 'windows') {
shell.exec('npm run dist:windows')
shell.mv('dist/squirrel-windows/*', '_dist/')
shell.find('_dist').filter((f) => f.endsWith('.exe')).forEach((f) => {
shell.mv(f, f.replace('Tc Setup ', 'tc-setup-win-'))
})
} else if (platform === 'linux') {
shell.exec('npm run dist:linux')
shell.mv('dist/*.AppImage', '_dist/')
shell.find('_dist').filter((f) => f.endsWith('.AppImage')).forEach((f) => {
shell.mv(f, f.replace('Tc-', 'tc-linux-').replace('-x86_64', ''))
})
} else if (platform === 'mac') {
shell.exec('npm run dist:mac')
shell.mv('dist/*.dmg', '_dist/')
shell.mv('dist/*.zip', '_dist/')
shell.find('_dist').filter((f) => f.endsWith('.dmg')).forEach((f) => {
shell.mv(f, f.replace('Tc', 'tc-setup-mac'))
})
shell.find('_dist').filter((f) => f.endsWith('.zip')).forEach((f) => {
const newName = f.replace('-mac', '').replace('Tc', 'tc-mac')
shell.mv(f, newName)
})
}
}