forked from zulip/zulip-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (48 loc) · 1.65 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
'use strict';
const gulp = require('gulp');
const electron = require('electron-connect').server.create({
verbose: true
});
const tape = require('gulp-tape');
const tapColorize = require('tap-colorize');
const ts = require('gulp-typescript');
const tsProject = ts.createProject('tsconfig.json');
const glob = require('glob');
const {execSync} = require('child_process');
const baseFilePattern = 'app/+(main|renderer)/**/*';
const globOptions = {cwd: __dirname};
const jsFiles = glob.sync(baseFilePattern + '.js', globOptions);
const tsFiles = glob.sync(baseFilePattern + '.ts', globOptions);
if (jsFiles.length !== tsFiles.length) {
const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx';
console.log('Compiling typescript files...');
execSync(`${npx} tsc`);
}
gulp.task('compile', () => tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest('app')));
gulp.task('dev', () => {
// Start browser process
electron.start(['--electron-connect']);
// Restart browser process
gulp.watch('app/main/*.ts', gulp.series('compile', 'restart:browser'));
// Reload renderer process
gulp.watch('app/renderer/css/*.css', gulp.series('reload:renderer'));
gulp.watch('app/renderer/*.html', gulp.series('reload:renderer'));
gulp.watch('app/renderer/js/**/*.ts', gulp.series('compile', 'reload:renderer'));
});
gulp.task('restart:browser', done => {
electron.stop();
electron.restart(['--electron-connect']);
done();
});
gulp.task('reload:renderer', done => {
// Reload renderer process
electron.reload();
done();
});
gulp.task('test-e2e', () => gulp.src('tests/*.js')
.pipe(tape({
reporter: tapColorize()
})));
gulp.task('default', gulp.parallel('dev', 'test-e2e'));