-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
86 lines (71 loc) · 2.3 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
const { src, dest, series, parallel, watch: w } = require('gulp');
const del = require('del');
const path = require('path');
const zip = require('gulp-zip');
const concat = require('gulp-concat');
const stripJsonComments = require('gulp-strip-json-comments');
const ts = require("gulp-typescript");
const sass = require('gulp-sass');
const { fstat, existsSync } = require('fs');
sass.compiler = require('node-sass');
// build src -> dist
var tsProject = ts.createProject("tsconfig.json");
function cleanBuild() {
return del(["dist"]);
}
function compileTypescript() {
return tsProject.src()
.pipe(tsProject()).js
.pipe(dest("dist"));
}
function compileSass() {
return src("src/**/*.scss")
.pipe(sass().on('error', sass.logError))
.pipe(concat("main.css"))
.pipe(dest("./dist"));
}
function stripJson() {
return src('src/**/*.json')
.pipe(stripJsonComments())
.pipe(dest('dist/'));
}
function copyMisc() {
return src(['src/**', '!src/**/*.json', '!src/**/*.scss', '!src/**/*.ts'])
.pipe(dest('dist/'));
}
const build = parallel(compileTypescript, compileSass, stripJson, copyMisc);
exports.clean = cleanBuild;
exports.default = build;
// install dist -> data
let dataPath = "";
if (existsSync(process.env.FOUNDRY_VTT_DATA_PATH)) {
dataPath = process.env.FOUNDRY_VTT_DATA_PATH;
} else if (existsSync(process.env.LOCALAPPDATA)) {
dataPath = path.join(process.env.LOCALAPPDATA, 'FoundryVTT');
} else if (existsSync(process.env.HOME + '/Library/Application Support')) {
dataPath = path.join(process.env.HOME, 'Library', 'Application Support', 'FoundryVTT');
} else {
throw Error("FOUNDRY_VTT_DATA_PATH not set");
}
const deployPath = path.join(dataPath, 'Data', 'systems', 'fmmua') + '/';
function cleanDeploy() {
return del([deployPath], {force: true});
}
function deploy() {
return src(['dist/**'])
.pipe(dest(deployPath));
}
exports.install = series(build, cleanDeploy, deploy);
exports.watch = function() {
w('src/**', build);
}
exports['watch-install'] = series(cleanDeploy, deploy, function watch() {
w('src/**', series(build, deploy));
});
// publish dist -> zip
function publish() {
return src('dist/**')
.pipe(zip('fmmua.zip'))
.pipe(dest('rel/'));
}
exports.release = series(cleanBuild, build, publish);