-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
51 lines (40 loc) · 1.16 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
'use strict'
const gulp = require('gulp')
const mocha = require('gulp-mocha')
const ts = require('typescript')
const gulpTslint = require('gulp-tslint')
const tslint = require('tslint')
const CI = process.env.CI === 'true'
const entrypoint = require('./package.json')['main']
const paths = {
sources: ['./scepter.ts', 'lib/**/*.ts'],
gulp: ['./gulpfile.js'],
modules: ['./modules/**/*'],
tests: ['test/**/*.test.js'],
testsSetup: ['./test/setup.js']
}
const all = Array.prototype.concat.apply([], Object.keys(paths).map(x => paths[x]))
function style () {
const program = tslint.Linter.createProgram('./tsconfig.json', '.')
ts.getPreEmitDiagnostics(program)
return gulp.src(all.concat('./gulpfile.js'))
.pipe(gulpTslint({ program }))
.pipe(gulpTslint.report())
}
function unit () {
return gulp.src(paths.tests, { read: false })
.pipe(mocha({
require: paths.testsSetup,
reporter: CI ? 'spec' : 'nyan'
}))
}
function watch () {
gulp.watch(paths.sources, unit)
gulp.watch(all, style)
}
const test = gulp.series(style, unit)
exports.watch = watch
exports.unit = unit
exports.style = style
exports.test = test
exports.default = test