-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
79 lines (68 loc) · 2.03 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
75
76
77
78
79
const gulp = require("gulp");
const del = require("del");
const vinylPaths = require("vinyl-paths");
const runSequence = require("run-sequence");
const ts = require("gulp-typescript");
const to5 = require("gulp-babel");
const replace = require("gulp-replace");
const mocha = require("gulp-spawn-mocha");
const clean = require("gulp-clean");
const tsProject = ts.createProject("tsconfig.json", {
typescript: require("typescript")
});
const outputPath = "dist/";
const dtsFile = outputPath + "fw-model.d.ts";
gulp.task("clean", function() {
return gulp.src([outputPath])
.pipe(vinylPaths(del));
});
gulp.task("build-dts", function() {
return require("dts-generator").default({
name: "fw-model",
baseDir: "./src",
files: ["index.ts"],
out: dtsFile
});
});
gulp.task("dts-fix", function() {
return gulp.src(dtsFile)
.pipe(replace("declare module 'fw-model/index'", "declare module 'fw-model'"))
.pipe(gulp.dest(outputPath));
});
gulp.task('build-common', function() {
return gulp.src(["src/**/*.ts", "typings/**/*.d.ts"])
.pipe(ts(tsProject))
.pipe(to5({
modules: "common"
}))
.pipe(gulp.dest(outputPath));
});
gulp.task('build', function(callback) {
return runSequence(
'clean',
'build-common',
'build-dts',
'dts-fix',
callback);
});
gulp.task('test-clean', function() {
return gulp.src(["src/**/*.js", "test/**/*.js"], { read: false })
.pipe(clean());
});
gulp.task('run-test', function() {
return gulp.src(["src/**/*.ts", "typings/**/*.d.ts", "test/**/*.ts"], { base: "." })
.pipe(ts(tsProject))
.pipe(to5({
modules: "common"
}))
.pipe(gulp.dest("."))
.pipe(mocha({
require: ["babel-polyfill"]
}));
});
gulp.task('test', function(callback) {
return runSequence('run-test', 'test-clean', callback);
});
gulp.task('test-tdd', function() {
return gulp.watch(["src/**/*.ts", "test/**/*.ts"], ['test']);
});