-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
55 lines (43 loc) · 1.17 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
const gulp = require('gulp'),
typeScript = require('gulp-typescript')
const arg = (argList => {
let arg = {},
opt, thisOpt, curOpt
argList.forEach((item, index) => {
thisOpt = item.trim()
opt = thisOpt.replace(/^\-+/, '')
if (opt === thisOpt) {
// argument value
if (curOpt) arg[curOpt] = opt
curOpt = null
} else {
// argument name
curOpt = opt
arg[curOpt] = true
}
})
return arg;
})(process.argv)
const typeScriptProject = typeScript.createProject('tsconfig.json', {
target: arg.target || 'es6',
module: arg.module || 'es2015'
}),
typeScriptProjectTest = typeScript.createProject('./test/tsconfig.json')
function build() {
return typeScriptProject
.src()
.pipe(typeScriptProject())
.pipe(gulp.dest(`lib/${arg.module}`))
}
function buildTests() {
return gulp
.src(['test/src/**/*.ts'])
.pipe(typeScriptProjectTest())
.pipe(gulp.dest(`test/build`))
}
gulp.task('build', build)
gulp.task('build:test', buildTests)
gulp.task('watching', () => {
gulp.watch('test/src/**/*.ts', buildTests)
gulp.watch(['src/**/*.ts', 'src/**/*.js'], build)
})