This repository has been archived by the owner on Mar 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
gulpfile.js
69 lines (58 loc) · 1.9 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
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
const gulp = require('gulp');
const path = require('path');
const ts = require('gulp-typescript');
const log = require('gulp-util').log;
const typescript = require('typescript');
const sourcemaps = require('gulp-sourcemaps');
const mocha = require('gulp-mocha');
const tslint = require('gulp-tslint');
var sources = [
'src',
'test',
'typings/main'
].map(function(tsFolder) { return tsFolder + '/**/*.ts'; });
var lintSources = [
'src',
'test'
].map(function(tsFolder) { return tsFolder + '/**/*.ts'; });
var projectConfig = {
noImplicitAny: false,
target: 'ES5',
module: 'commonjs',
declaration: true,
typescript: typescript,
moduleResolution: "node"
};
gulp.task('build', function () {
return gulp.src(sources, { base: '.' })
.pipe(sourcemaps.init())
.pipe(ts(projectConfig)).js
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: 'file:///' + __dirname }))
.pipe(gulp.dest('out'));
});
gulp.task('watch', ['build'], function(cb) {
log('Watching build sources...');
return gulp.watch(sources, ['build']);
});
gulp.task('default', ['build']);
gulp.task('tslint', function() {
return gulp.src(lintSources, { base: '.' })
.pipe(tslint())
.pipe(tslint.report('verbose'));
});
function test() {
return gulp.src('out/test/**/*.test.js', { read: false })
.pipe(mocha({ ui: 'tdd' }))
.on('error', function(e) {
log(e ? e.toString() : 'error in test task!');
this.emit('end');
});
}
gulp.task('build-test', ['build'], test);
gulp.task('test', test);
gulp.task('watch-build-test', ['build', 'build-test'], function() {
return gulp.watch(sources, ['build', 'build-test']);
});