-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
109 lines (95 loc) · 2.34 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
const del = require('del')
const exec = require('child_process').exec
const gulp = require('gulp')
const eslint = require('gulp-eslint')
const imagemin = require('gulp-imagemin')
const mocha = require('gulp-mocha')
const sourcemaps = require('gulp-sourcemaps')
const typedoc = require('gulp-typedoc')
const typescript = require('gulp-typescript')
const tslint = require('gulp-tslint')
const dir = {
build: 'dist',
coverage: 'coverage',
doc: 'doc',
images: 'images',
src: 'src',
test: 'test'
}
const tsProject = typescript.createProject('tsconfig.json')
gulp.task('eslint', () => {
return gulp
.src([
'**.js',
'!node_modules/**',
`!${dir.build}/**`,
`!${dir.coverage}/**`,
`!${dir.doc}/**`
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
})
gulp.task('tslint', () => {
return gulp
.src(`${dir.src}/**.ts`)
.pipe(tslint())
.pipe(tslint.report())
})
gulp.task('check-links', (cb) => {
exec('./node_modules/markdown-link-check/markdown-link-check README.md', (err, stdout, stderr) => {
if (stderr != null && stderr !== '') {
console.error(stderr)
}
cb(err)
})
})
gulp.task('lint', ['eslint', 'tslint'])
gulp.task('build', ['image'], () => {
return tsProject
.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dir.build))
})
gulp.task('watch', () => {
gulp.watch('*.js', ['eslint'])
gulp.watch(`${dir.src}/**.ts`, ['build'])
gulp.watch(`${dir.src}/**.ts`, ['tslint'])
gulp.watch(`${dir.test}/**.js`, ['eslint'])
})
gulp.task('pre-test', ['build', 'lint'])
gulp.task('test', ['pre-test', 'check-links'], () => {
return gulp
.src([`${dir.test}/**.js`])
.pipe(mocha())
})
gulp.task('doc', () => {
return gulp
.src(['src/**.ts'])
.pipe(typedoc({
// TypeScript options
includeDeclarations: true,
excludeExternals: true,
// Output options
out: dir.doc,
json: `${dir.doc}/output.json`,
// TypeDoc options
readme: 'README.md',
version: true
}))
})
gulp.task('image', () => {
return gulp.src(`${dir.images}/**`)
.pipe(imagemin())
.pipe(gulp.dest(`${dir.images}/`))
})
gulp.task('clean', () => {
return del([
`${dir.coverage}/`,
`${dir.build}/`,
'**.log'
])
})
gulp.task('default', ['build'])