forked from AKST/nuimo-client.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
74 lines (63 loc) · 2.23 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
var gulp = require('gulp');
var tslint = require('gulp-tslint');
var exec = require('child_process').exec;
var jasmine = require('gulp-jasmine');
var gulp = require('gulp-help')(gulp);
var tsconfig = require('gulp-tsconfig-files');
var path = require('path');
var inject = require('gulp-inject');
var gulpSequence = require('gulp-sequence');
var del = require('del');
var dtsGenerator = require('dts-generator');
require('dotbin');
var tsFilesGlob = (function (c) {
return c.filesGlob || c.files || '**/*.ts';
})(require('./tsconfig.json'));
var appName = (function (p) {
return p.name;
})(require('./package.json'));
gulp.task('update-tsconfig', 'Update files section in tsconfig.json', function () {
gulp.src(tsFilesGlob).pipe(tsconfig());
});
gulp.task('clean', 'Cleans the generated js files from lib directory', function () {
return del([
'lib/**/*'
]);
});
gulp.task('tslint', 'Lints all TypeScript source files', function () {
return gulp.src(tsFilesGlob)
.pipe(tslint())
.pipe(tslint.report('verbose'));
});
gulp.task('gen-def', 'Generate a single .d.ts bundle containing external module declarations exported from TypeScript module files', function (cb) {
return dtsGenerator.default({
name: appName,
project: '.',
out: './lib/' + appName + '.d.ts',
exclude: ['node_modules/**/*.d.ts', 'typings/**/*.d.ts']
});
});
gulp.task('_build', 'INTERNAL TASK - Compiles all TypeScript source files', function (cb) {
exec('tsc --version', function (err, stdout, stderr) {
console.log('TypeScript ', stdout);
if (stderr) {
console.log(stderr);
}
});
return exec('tsc', function (err, stdout, stderr) {
console.log(stdout);
if (stderr) {
console.log(stderr);
}
cb(err);
});
});
//run tslint task, then run update-tsconfig and gen-def in parallel, then run _build
gulp.task('build', 'Compiles all TypeScript source files and updates module references', gulpSequence('tslint', ['update-tsconfig', 'gen-def'], '_build'));
gulp.task('test', 'Runs the Jasmine test specs', ['build'], function () {
return gulp.src('test/*.js')
.pipe(jasmine());
});
gulp.task('watch', 'Watches ts source files and runs build on change', function () {
gulp.watch('src/**/*.ts', ['build']);
});