-
Notifications
You must be signed in to change notification settings - Fork 22
/
gulpfile.js
74 lines (62 loc) · 1.65 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
const gulp = require('gulp');
const ts = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const jeditor = require('gulp-json-editor');
const merge = require('merge-stream');
var del = require('del');
const tsProject = ts.createProject('tsconfig.json');
const dirs = {
dist: ['dist']
};
const editPackageSnapcraft = () => {
return gulp.src('package.json')
.pipe(jeditor(function(json) {
json.devDependencies = {};
return json;
}))
.pipe(gulp.dest('./'));
};
const movePackage = () => {
return gulp.src('package.json')
.pipe(gulp.dest(dirs.dist));
};
const moveReadme = () => {
return gulp.src('readme.md')
.pipe(gulp.dest(dirs.dist));
};
const moveLocals = () => {
return gulp.src('i18n/**/*.json')
.pipe(gulp.dest(dirs.dist + '/i18n'));
};
const compileProd = () => {
return tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest(dirs.dist));
};
const compileTest = () => {
const tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject());
return merge(tsResult, tsResult.js)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dirs.dist));
};
const watch = () => {
gulp.watch(['src/**/*.ts', 'cli.ts', 'i18n/**/*.json'], buildTest);
};
const delDist = () => {
return del(['dist/**/*']);
};
const build = gulp.series(delDist, compileProd, moveLocals);
const buildMeta = gulp.parallel(movePackage, moveReadme);
const buildTest = gulp.series(compileTest, moveLocals);
const dev = gulp.series(buildTest, watch);
const snapcraft = gulp.series(compileProd, editPackageSnapcraft);
module.exports = {
build,
buildMeta,
buildTest,
dev,
snapcraft,
default: build
};