-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
72 lines (60 loc) · 1.69 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
var path = require("path");
var del = require("del");
var gulp = require("gulp");
var mocha = require("gulp-mocha");
var eslint = require("gulp-eslint");
var ts = require("gulp-typescript");
var merge = require("merge2");
var libSources = ["index.ts", "lib/**/*.ts"];
var testSources = ["test/**/*.ts"];
var allSources = libSources.concat(testSources);
var builtTestFiles = ["dist/test/**/*.js"];
function tsDestPath(destFolder) {
return file => {
const targetFilePath = path.join(
destFolder,
file.path.replace(__dirname, "")
);
const targetDirectory = path.dirname(targetFilePath);
return targetDirectory;
};
}
gulp.task("clean", function() {
return del(["definitions/**/*", "dist/**/*"]);
});
gulp.task("build:copy-assets", function() {
return gulp.src(["test/*.PublishSettings"]).pipe(gulp.dest("dist/test"));
});
gulp.task("build:typescript", function() {
var tsResult = gulp.src(allSources).pipe(ts.createProject("tsconfig.json")());
return merge([
tsResult.dts.pipe(gulp.dest(tsDestPath("definitions"))),
tsResult.js.pipe(gulp.dest(tsDestPath("dist")))
]);
});
gulp.task("build", gulp.parallel("build:copy-assets", "build:typescript"));
gulp.task("lint", function() {
return gulp
.src(allSources)
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task(
"watch-lint",
gulp.series("lint", function() {
return gulp.watch(allSources, ["lint"]);
})
);
gulp.task(
"test",
gulp.series("build", function() {
return gulp.src(builtTestFiles).pipe(mocha());
})
);
gulp.task(
"watch-test",
gulp.series("test", function() {
return gulp.watch(allSources, ["test"]);
})
);
gulp.task("watch", gulp.parallel("watch-lint", "watch-test"));