-
Notifications
You must be signed in to change notification settings - Fork 14
/
gulpfile.js
144 lines (127 loc) · 3.7 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
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
138
139
140
141
142
143
144
var gulp = require("gulp");
var replace = require("gulp-replace");
var runSequence = require("run-sequence");
var exec = require('child_process').exec;
var util = require('util');
var change = require('gulp-change');
var beautify = require('js-beautify').js_beautify;
var concat = require('gulp-concat');
var filter = require('gulp-filter');
var ignore = require('gulp-ignore');
gulp.task("prep_1_2_main" +
"", function() {
return gulp.src(["./1.2/packages/*.d.ts"])
.pipe(concat('main.d.ts'))
.pipe(gulp.dest("1.2/"));
});
gulp.task("prep_1_2_browser" +
"", function() {
return gulp.src([
"./1.2/packages/*.d.ts",
"!./1.2/packages/*_main.d.ts"
])
.pipe(ignore('*tools_main.d.ts'))
.pipe(concat('browser.d.ts'))
.pipe(gulp.dest("1.2/"));
});
gulp.task("1_2_bundle", function(callback) {
exec("cd 1.2 && typings bundle --global -o out/main.d.ts",
function(err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
callback();
});
});
gulp.task("1_2", function(callback) {
runSequence("prep_1_2_main", "prep_1_2_browser", "1_2_bundle", callback);
});
function performChange(content) {
var cleanContent = content
.replace(/\/\/\/\s\<reference path=".*"\s\/>\n?/g, "")
.replace(/^\n*\s*$/, '');
var newModuleContent = cleanContent
.replace(/declare\s/g, "");
var fname = this.fname
.replace(".d.ts", "")
.replace("_main", "")
.replace("_browser", "");
return beautify(
util.format(
"%s\ndeclare module \"meteor/%s\" {%s}",
cleanContent, fname, newModuleContent), {
indent_size: 2,
indent_char: " "
})
.replace(/declare\r?\n/g, "declare ")
// removing space before/after ? for optional params
.replace(/\s\?\s?/g, '?') + '\n';
}
gulp.task("prep_1_3_main", function() {
return gulp.src([
"./1.2/packages/*.d.ts",
"./1.3/packages/*.d.ts"
])
.pipe(change(performChange))
.pipe(concat('main.d.ts'))
.pipe(gulp.dest("1.3/"));
});
gulp.task("prep_1_3_browser", function() {
return gulp.src([
"./1.2/packages/*.d.ts",
"./1.3/packages/*.d.ts",
"!./1.2/packages/*_main.d.ts",
"!./1.3/packages/*_main.d.ts"
])
.pipe(ignore('*tools_main.d.ts'))
.pipe(change(performChange))
.pipe(concat('browser.d.ts'))
.pipe(gulp.dest("1.3/"));
});
gulp.task("1_3_bundle", function(callback) {
exec("cd 1.3 && typings bundle --global -o out/main.d.ts",
function(err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
callback();
});
});
gulp.task("1_3", function(callback) {
runSequence("prep_1_3_main", "prep_1_3_browser", "1_3_bundle", callback);
});
gulp.task("prep_1_4_main", function() {
return gulp.src([
"./1.2/packages/*.d.ts",
"./1.3/packages/*.d.ts",
"./1.4/packages/*.d.ts"])
.pipe(change(performChange))
.pipe(concat('main.d.ts'))
.pipe(gulp.dest("1.4/"));
});
gulp.task("prep_1_4_browser", function() {
return gulp.src([
"./1.2/packages/*.d.ts",
"./1.3/packages/*.d.ts",
"./1.4/packages/*.d.ts",
"!./1.2/packages/*_main.d.ts",
"!./1.3/packages/*_main.d.ts",
"!./1.4/packages/*_main.d.ts"
])
.pipe(ignore('*tools_main.d.ts'))
.pipe(change(performChange))
.pipe(concat('browser.d.ts'))
.pipe(gulp.dest("1.4/"));
});
gulp.task("1_4_bundle", function(callback) {
exec("cd 1.4 && typings bundle --global -o out/main.d.ts",
function(err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
callback();
});
});
gulp.task("1_4", function(callback) {
runSequence("prep_1_4_main", "prep_1_4_browser", "1_4_bundle", callback);
});
gulp.task("build", function(callback) {
runSequence("1_2", "1_3", "1_4", callback);
});