This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
/
gulpfile.js
125 lines (111 loc) Β· 3.22 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const gulp = require('gulp')
const shell = require('child_process').exec
const spawn = require('child_process').spawn
const babel = require('gulp-babel')
const env = require('gulp-env')
const less = require('gulp-less')
const path = require('path')
const istanbul = require('gulp-babel-istanbul')
const injectModules = require('gulp-inject-modules')
const mocha = require('gulp-mocha')
const LessPluginCleanCSS = require('less-plugin-clean-css')
const cleancss = new LessPluginCleanCSS({ advanced: true })
const LESS_FILES = './app/static/styles/*.less'
const ELECTRON = __dirname + '/node_modules/.bin/electron'
const DEBUG = false
let p
let args = ['.']
// Start the electron process.
async function electron () {
// kill previous spawned process
if (p) {
p.kill()
}
if (DEBUG) args.unshift('--inspect=5858')
// `spawn` a child `gulp` process linked to the parent `stdio`
p = await spawn(ELECTRON, args, {
stdio: 'inherit',
env: {
...process.env
}
})
}
gulp.task('run', electron)
gulp.task('watch', function (done) {
gulp.watch(LESS_FILES, gulp.series('less'))
gulp.watch(['./app/*.js', './app/src/*.js', './app/core/*.js'], gulp.series('run'))
done()
})
gulp.task('nodev', function () {
return shell(
// start electron main and render process
`node_modules/.bin/electron script/resolveNodeV.js`,
function (err, stdout, stderr) {
console.log(stdout)
console.log(stderr)
}
)
})
gulp.task('less', function () {
return gulp
.src('./app/static/styles/*.less')
.pipe(
less({
paths: [path.join(__dirname, 'less', 'includes')],
plugins: [cleancss]
})
)
.pipe(gulp.dest('./app/static/styles/'))
})
/* TEST */
gulp.task('test', () => {
shell(
// Run test stuff
'mocha --require babel-core/register test/'
)
})
gulp.task('coverage', function (cb) {
const envs = env.set({
TEST_RUN: true
})
gulp
.src('./app/core/**/*.js')
.pipe(envs)
.pipe(istanbul())
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp
.src('test/*.js')
.pipe(babel())
.pipe(injectModules())
.pipe(mocha())
.pipe(istanbul.writeReports())
.on('end', cb)
})
})
/* BUILD */
gulp.task('rebuildni', () => {
shell(
// start node inspector server
'node_modules/.bin/node-pre-gyp --target=$(node_modules/.bin/electron -v | sed s/\v//g) --runtime=electron --fallback-to-build --directory node_modules/v8-debug/ --dist-url=https://atom.io/download/atom-shell reinstall && node_modules/.bin/node-pre-gyp --target=$(node_modules/.bin/electron -v | sed s/\v//g) --runtime=electron --fallback-to-build --directory node_modules/v8-profiler/ --dist-url=https://atom.io/download/atom-shell reinstall'
)
})
gulp.task('buildnative', () => {
shell(
// start build the native module
'./node_modules/.bin/electron-rebuild #1'
)
})
gulp.task('ni', () => {
shell(
// start node inspector server
'ELECTRON_RUN_AS_NODE=true node_modules/.bin/electron node_modules/node-inspector/bin/inspector.js'
)
})
gulp.task('driver', () => {
shell(
// Run chromedriver
'./node_modules/chromedriver/bin/chromedriver'
)
})
gulp.task('default', gulp.series('less', 'watch', 'run'))