forked from superpowers/superpowers-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (42 loc) · 1.57 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
"use strict";
const gulp = require("gulp");
const tasks = [];
// Jade
const jade = require("gulp-jade");
const rename = require("gulp-rename");
const fs = require("fs");
const i18n = require("./scripts/i18n.js");
const languageCodes = fs.readdirSync(i18n.localesPath);
languageCodes.push("none");
for (const languageCode of languageCodes) {
const locale = i18n.loadLocale(languageCode);
gulp.task(`jade-index-${languageCode}`, () => {
const result = gulp.src("./src/renderer/index.jade").pipe(jade({ locals: { t: i18n.makeT(locale) } }));
if (languageCode !== "en") result.pipe(rename({ extname: `.${languageCode}.html` }));
return result.pipe(gulp.dest("public/renderer"));
});
tasks.push(`jade-index-${languageCode}`);
}
// Stylus
const stylus = require("gulp-stylus");
gulp.task("stylus-index", () => gulp.src("./src/renderer/index.styl").pipe(stylus({ compress: true })).pipe(gulp.dest("public/renderer")));
tasks.push("stylus-index");
// TypeScript
const ts = require("gulp-typescript");
const tslint = require("gulp-tslint");
// Node
const tsProject = ts.createProject("./src/tsconfig.json");
gulp.task("typescript", () => {
let failed = false;
const tsResult = tsProject.src()
.pipe(tslint())
.pipe(tslint.report("prose", { emitError: false }))
.on("error", (err) => { throw err; })
.pipe(tsProject())
.on("error", () => { failed = true; })
.on("end", () => { if (failed) throw new Error("There were TypeScript errors."); });
return tsResult.js.pipe(gulp.dest("./public"));
});
tasks.push("typescript");
// All
gulp.task("default", tasks);