-
Notifications
You must be signed in to change notification settings - Fork 85
/
gulpfile.js
104 lines (87 loc) · 2.83 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
const { src, dest, series, parallel, watch } = require("gulp");
const sass = require("gulp-sass");
const rename = require("gulp-rename");
const zip = require("gulp-zip");
const merge = require("merge-stream");
const os = require("os");
const path = require("path");
const buildStyles = () => {
console.log("Compiling CSS files...");
sass.compiler = require("node-sass");
const regular = src(["*.scss", "!*-cyrillic.scss", "!*-alt.scss"])
.pipe(sass({ outputStyle: "expanded" }).on("error", sass.logError))
.pipe(dest("dist/ursine"));
const cyrillic = src("*-cyrillic.scss")
.pipe(sass({ outputStyle: "expanded" }).on("error", sass.logError))
.pipe(dest("dist/ursine-cyrillic"));
const alt = src("*-alt.scss")
.pipe(sass({ outputStyle: "expanded" })).on("error", sass.logError)
.pipe(dest("dist/ursine-alt"));
return merge(regular, cyrillic, alt);
};
const includeAssets = () => {
const regular = src([
"ursine/*.png",
"ursine/FiraMono-*.ttf",
"ursine/Adelle-*.woff",
"ursine/AvenirNextLTPro-*.woff"
]).pipe(dest("dist/ursine/ursine"));
const cyrillic = src([
"ursine/*.png",
"ursine/FiraMono-*.ttf",
"ursine/AdelleCyrillic-*.woff",
"ursine/AvenirNextCyr-*.woff"
]).pipe(dest("dist/ursine-cyrillic/ursine"));
const alt = src([
"ursine/*.png",
"ursine/FiraMono-*.ttf",
"ursine/RobotoSlab-*.ttf",
"ursine/OpenSans-*.ttf"
]).pipe(dest("dist/ursine-alt/ursine"));
console.log("Including assets...");
return merge(regular, cyrillic, alt);
};
const makeZip = () => {
const regular = src("dist/ursine/**").pipe(zip("Ursine.zip"));
const cyrillic = src("dist/ursine-cyrillic/**").pipe(zip("Ursine_Cyrillic.zip"));
const alt = src("dist/ursine-alt/**").pipe(zip("Ursine_Alt.zip"));
console.log(`Building releases...`);
return merge(regular, cyrillic, alt).pipe(dest("./release"));
};
const dev = () => {
let themeLocation;
switch (os.type()) {
case "Windows_NT":
themeLocation = `${process.env.APPDATA}\\Typora\\themes`;
break;
case "Darwin":
themeLocation = `${process.env.HOME}/Library/Application Support/abnerworks.Typora/themes`;
break;
case "Linux":
themeLocation = "~/.config/Typora/themes";
break;
}
// Watch styles
watch(
["*.scss", "ursine/*.scss"],
{ ignoreInitial: false },
function styleWatcher() {
return themeLocation
? buildStyles().pipe(dest(themeLocation))
: buildStyles();
}
);
// Watch assets
watch(
["ursine/*.(ttf|woff|png)"],
{ ignoreInitial: false },
function assetWatcher() {
return themeLocation
? includeAssets().pipe(dest(path.join(themeLocation, "ursine")))
: includeAssets();
}
);
};
exports.default = parallel(buildStyles, includeAssets);
exports.release = series(exports.default, makeZip);
exports.dev = dev;