-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
73 lines (63 loc) · 2.31 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
var gulp = require('gulp'),
tsc = require('gulp-typescript'),
tslint = require('gulp-tslint'),
sourcemaps = require('gulp-sourcemaps'),
del = require('del'),
tsProject = tsc.createProject('tsconfig.json'),
mocha = require('gulp-mocha'),
path = require('path'),
rename = require('gulp-rename');
// or requiring in ES5
var tslint = require("gulp-tslint");
var merge = require('merge2');
var shell = require('gulp-shell');
gulp.task('ts-lint', ['clean-ts'], function () {
return gulp.src(['./**/*.ts', '!typings/**/*.ts', '!node_modules/**/*.ts']).pipe(tslint({
formatter: "prose"
}))
.pipe(tslint.report());
});
/**
* Compile TypeScript and include references to library and app .d.ts files.
*/
gulp.task('compile-ts', ['ts-lint'], function () {
var tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsc(tsProject));
return merge([
tsResult.dts.pipe(gulp.dest('dist')),
tsResult.js.pipe(sourcemaps.write('.', {
// Return relative source map root directories per file.
includeContent: false,
sourceRoot: function (file) {
var sourceFile = path.join(file.cwd, file.sourceMap.file);
return "../" + path.relative(path.dirname(sourceFile), __dirname);
}
})).pipe(gulp.dest('dist'))
]);
});
gulp.task('copy-json', ['compile-ts'], function () {
var sourceJsonFiles = [
'./src/*.json', //path to typescript files
];
return gulp.src(sourceJsonFiles).pipe(gulp.dest('dist/src/'));
});
gulp.task('clean-ts', function (cb) {
var typeScriptGenFiles = [
'./dist/**/*.*' // path to all JS files auto gen'd by editor
];
// delete the files
return del(typeScriptGenFiles, cb);
});
gulp.task('test', ['copy-json'], function () {
return gulp.src('dist/test/**/*.spec.js', {read: false})
// gulp-mocha needs filepaths so you can't have any plugins before it
.pipe(mocha({reporter: 'spec', timeout: '360000'})).once('error', () => {
process.exit(1);
});
});
gulp.task('pack', ['test'], shell.task([
'npm pack'
])
);
gulp.task('default', ['clean-ts', 'ts-lint', 'compile-ts', 'copy-json', 'test']);