-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
54 lines (45 loc) · 1.35 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
'use strict';
let gulp = require('gulp');
const SOURCES = 'src/**/*.ts';
const TEST_SOURCES = 'src/**/*.{mock,spec}.ts';
const MOCKS = 'src/**/*mock.ts';
const TYPEDEPS = 'src/typings/**/*.d.ts';
const COMPILED_TEST_SOURCES = 'dist/**/*.spec.js';
const DEFAULT_TASKS = ['test', 'tslint'];
let destination = gulp.dest('dist');
/**
* Typescript gets compiled from src/ to dist/
*/
let gts = require('gulp-typescript');
let tsProject = gts.createProject('tsconfig.json');
let ts = gts(tsProject);
gulp.task('build:tsc', function() {
return gulp.src([SOURCES]).pipe(ts).pipe(destination);
});
/**
* Lint checks all of our code.
*/
let tslintconfig = require('./tslint.json');
let tslint = require('gulp-tslint');
gulp.task('tslint', function() {
return gulp.src([SOURCES, `!${TYPEDEPS}`, `!${MOCKS}`])
.pipe(tslint({configuration: tslintconfig}))
.pipe(tslint.report('prose'));
});
/**
* Mocha tests *.spec.js in dist.
*/
let mochaconfig = require('./mochaconfig.json');
let mocha = require('gulp-mocha')(mochaconfig);
gulp.task('test', ['build:tsc'], function() {
return gulp.src([COMPILED_TEST_SOURCES]).pipe(mocha);
});
/**
* Some default tasks.
*/
const DEFAULT = ['default'];
gulp.task('default', DEFAULT_TASKS);
gulp.task('watch', DEFAULT, function() { gulp.watch([SOURCES], DEFAULT); });
if (require.main === module) {
gulp.runTask('default');
}