-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.ts
executable file
·137 lines (103 loc) · 3.15 KB
/
Gulpfile.ts
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
///<reference path="typings/index.d.ts"/>
var gulp = require("gulp");
var gutil = require("gulp-util");
var merge = require("merge2");
var insert = require("gulp-insert");
var sourcemaps = require("gulp-sourcemaps");
var sync = require("gulp-config-sync");
var ts = require("gulp-typescript");
var typedoc = require("gulp-typedoc");
var uglify = require("gulp-uglify");
var tslint = require("gulp-tslint");
var mochaPhantomJS = require('gulp-mocha-phantomjs');
var shell = require("gulp-shell");
var rename = require("gulp-rename");
import mocha = require("gulp-mocha");
var minify = false;
var tslintOpts = {
//tslint: require("tslint")
};
var tsProject = ts.createProject("src/tsconfig.json", {
sortOutput: true,
noEmit: false,
declaration: true,
out: "dist/updraft.js"
});
gulp.task("compile", function() {
var tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
var dts = tsResult.dts
.pipe(insert.transform(function(contents: string, file: any) {
contents = contents.replace(/\/\/\/\s*\<reference path=".*"\s*\/\>\s*\n/ig, "");
contents += "declare module \"updraft\" {\n" +
" export = Updraft;\n" +
"}\n";
return contents;
}));
dts = tsResult.dts.pipe(gulp.dest("./"));
var js = tsResult.js;
js = js.pipe(insert.transform(function(contents: string, file: any) {
contents = contents.replace(/(Updraft = {})/g, "/* istanbul ignore next */ $1");
contents = contents.replace(/(var _a(,|;))/g, "/* istanbul ignore next */ $1");
return contents;
}));
if(minify) {
js = js.pipe(uglify());
}
js = js
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest("./"));
return merge([dts, js]);
});
gulp.task('coverage', ['compile'], shell.task([
"ts-node node_modules/istanbul/lib/cli.js cover node_modules/mocha/bin/_mocha test/*.ts"
]));
gulp.task("typedoc", function() {
return gulp.src(["src/*.ts"])
.pipe(typedoc({
module: "commonjs",
out: "./doc",
theme: "minimal",
name: "Updraft",
target: "es5",
mode: "file",
includeDeclarations: true
}));
});
gulp.task("watch", ["compile"], function() {
gulp.watch("src/*.ts", ["compile"]);
});
gulp.task("lint", function () {
return gulp.src(["src/*.ts", "test/*.ts"])
.pipe(tslint(tslintOpts))
.pipe(tslint.report("verbose"));
});
gulp.task("test", ["test-node", "test-phantomjs"]);
gulp.task("test-node", ["compile"], function () {
return gulp.src(["test/*.ts", "test/*.js"])
.pipe(mocha());
});
gulp.task('test-phantomjs', ["compile"], function() {
return gulp.src('./test/test.html')
.pipe(mochaPhantomJS({
"webSecurityEnabled": false,
"outputEncoding": "utf8",
"localToRemoteUrlAccessEnabled": true
}));
});
gulp.task('test-phantomjs-quiet', ["compile"], function() {
return gulp.src('./test/test.html')
.pipe(mochaPhantomJS({
"reporter": "dot",
"webSecurityEnabled": false,
"outputEncoding": "utf8",
"localToRemoteUrlAccessEnabled": true
}));
});
gulp.task("sync", function() {
return gulp.src(["bower.json"])
.pipe(sync())
.pipe(gulp.dest(".")); // write it to the same dir
});
gulp.task("default", ["compile", "coverage", "test-node", "test-phantomjs-quiet", "lint", /*"typedoc",*/ "sync"]);