-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
86 lines (75 loc) · 1.96 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
const gulp = require("gulp");
const rename = require("gulp-rename");
const sequence = require("gulp-sequence");
const sourcemaps = require("gulp-sourcemaps");
const ts = require("@notadd/gulp-typescript");
const tslint = require("gulp-tslint");
const packages = {
"email": ts.createProject("src/tsconfig.json"),
};
const dist = "package";
const source = "src";
const modules = Object.keys(packages);
gulp.task("default", function () {
tasks();
});
modules.forEach(module => {
gulp.task(module, () => {
gulp.src([
`${source}/**/*.original.graphql`,
`${source}/*.original.graphql`,
]).pipe(rename(function (path) {
path.basename = path.basename.replace(".original", ".types");
})).pipe(gulp.dest(`${dist}`));
return packages[module]
.src()
.pipe(tslint({
formatter: "verbose",
}))
.pipe(tslint.report({
emitError: false,
summarizeFailureOutput: true,
}))
.pipe(sourcemaps.init())
.pipe(packages[module]())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(dist));
});
});
gulp.task("build", function (cb) {
sequence("email", modules.filter((module) => module !== "email"), cb);
});
function tasks() {
modules.forEach(module => {
watchGraphql(source, module);
watchTypescript(source, module);
});
}
function watchGraphql(source, module) {
gulp.watch(
[
`${source}/${module}/**/*.graphql`,
`${source}/${module}/*.graphql`,
],
[
module,
]
).on("change", function (event) {
console.log("File " + event.path + " was " + event.type + ", running tasks...");
});
}
function watchTypescript(source, module) {
gulp.watch(
[
`${source}/${module}/**/*.ts`,
`${source}/${module}/**/*.tsx`,
`${source}/${module}/*.ts`,
`${source}/${module}/*.tsx`,
],
[
module,
]
).on("change", function (event) {
console.log("File " + event.path + " was " + event.type + ", running tasks...");
});
}