-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.ts
42 lines (35 loc) · 1.34 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
import * as env from "dotenv";
import * as fs from "fs";
import * as path from "path";
import Task, { Pipe, remove } from "./gulp/Task";
import TypescriptWatch from "./gulp/TypescriptWatch";
import { nameFunction } from "./gulp/Util";
import mocha = require("gulp-mocha");
import del = require("del");
fs.appendFileSync(".env", "");
env.config();
////////////////////////////////////
// Tasks
//
Task.create("mocha", Pipe.create("out/tests/Main.js", { read: false })
.pipe(() => mocha({ reporter: "even-more-min" }))
.on("error", () => process.exitCode = 1));
new Task("compile-test", remove("out"))
.then("compile", async () => new TypescriptWatch("src", "out").once())
.then("mocha")
.create();
new Task("watch", remove("out"))
.then("compile-test", async () => new TypescriptWatch("src", "out")
.onComplete(Task.get("mocha"))
.watch()
.waitForInitial())
.create();
Task.create("default", "watch");
new Task("deploy", nameFunction("remove WARD_DEPLOY_PATH", async () => {
if (!process.env.WARD_DEPLOY_PATH)
throw new Error("Cannot deploy, WARD_DEPLOY_PATH not set");
return del(process.env.WARD_DEPLOY_PATH, { force: true });
}))
.then("copy", Pipe.create("out/**/*").pipe(process.env.WARD_DEPLOY_PATH!))
.then("notify update", (cb) => fs.writeFile(path.join(process.env.WARD_DEPLOY_PATH!, "..", "update.notify"), "update", cb))
.create();