-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
56 lines (40 loc) · 1.4 KB
/
gulpfile.js
File metadata and controls
56 lines (40 loc) · 1.4 KB
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
const spawn = require('child_process').spawn;
const gulp = require('gulp');
const maps = require('gulp-sourcemaps');
const babel = require('gulp-babel');
const css = require('gulp-css');
/* Build */
gulp.task('build-css', function(){
return gulp.src('src/**/*.css')
.pipe(css())
.pipe(gulp.dest('app/'));
});
gulp.task('build-js', () => {
return gulp.src(['main.js', 'src/**/*.js', '!src/**/*.test.js'])
.pipe(maps.init())
.pipe(babel())
.pipe(maps.write('.'))
.pipe(gulp.dest('app/'));
});
gulp.task('build', ['build-css', 'build-js']);
/* Copy */
gulp.task('copy-html', () => {
return gulp.src('src/*.html').pipe(gulp.dest('app/'));
});
gulp.task('copy-assets', () => {
return gulp.src('assets/**/*').pipe(gulp.dest('app/assets'));
});
gulp.task('copy', ['copy-html', 'copy-assets']);
/* Execute */
const cmd = (name) => 'node_modules/.bin/' + name;
const args = (more) => Array.isArray(more) ? ['.'].concat(more) : ['.'];
const exit = () => process.exit();
gulp.task('start', ['copy', 'build'], () => {
spawn(cmd('electron'), args(), { stdio: 'inherit' }).on('close', exit);
});
gulp.task('release', ['copy', 'build'], () => {
spawn(cmd('electron-builder'), args(), { stdio: 'inherit' }).on('close', exit);
});
gulp.task('test', ['copy', 'build'], () => {
spawn(cmd('jest'), args(), { stdio: 'inherit' }).on('close', exit);
});