-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpFile.js
48 lines (40 loc) · 1.39 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
/// <binding Clean='clean' ProjectOpened='watch-ts' />
var os = require('os');
var gulp = require("gulp"),
ts = require("gulp-typescript"),
merge = require('merge2'),
insert = require('gulp-insert'),
sourcemaps = require('gulp-sourcemaps');
var mocha = require('gulp-mocha');
var rootDir = "file://" + __dirname;
process.on('uncaughtException', console.error.bind(console));
gulp.task('default', ['test'], function () {
// gulp.start('compile-ts');
// return gulp.watch('src/**/*.ts', ['compile-ts']);
});
gulp.task('test', function () {
return gulp.src('test/**.spec.js', {read: false})
.pipe(mocha({reporter: 'nyan'}));
});
// https://www.npmjs.com/package/gulp-typescript
gulp.task("compile-ts", [], function () {
var tsProject = ts.createProject(
'./tsconfig.json',
{
sortOutput: true,
typescript: require('typescript') // must be a project package dependency
});
var tsResult =
gulp.src('src/**', {base: 'src/'})
.pipe(sourcemaps.init())
.pipe(insert.prepend('"use strict";'))
.pipe(ts(tsProject));
return merge([
tsResult.dts
.pipe(gulp.dest('dist')),
tsResult.js
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: rootDir + "/src"}))
.pipe(gulp.dest('dist'))
]
);
});