This repository has been archived by the owner on Mar 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathgulpfile.js
80 lines (72 loc) · 2.1 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
var del = require('del');
var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var rename = require('gulp-rename');
var gulpTslint = require('gulp-tslint');
var ts = require('gulp-typescript');
var tslint = require('tslint');
var tsProject = ts.createProject('tsconfig.json');
var path = {
src: './src/',
dist: './dist/',
example: './examples/AdaptiveCards/',
tool: './tool/src/assets/AdaptiveCards/',
};
function clean() {
return del([path.dist, path.example, path.tool]);
}
function minifyImage() {
return gulp.src(path.src + 'Assets/**/*.png')
.pipe(imagemin())
.pipe(gulp.dest(path.dist + 'Assets'))
.pipe(gulp.dest(path.example + 'Assets'))
.pipe(gulp.dest(path.tool + 'Assets'))
.pipe(rename(function (opt) {
opt.basename = opt.basename.replace(/@[^.]*/, '');
return opt;
}));
}
function lintTs() {
var program = tslint.Linter.createProgram('./tsconfig.json');
return gulp.src([path.src + '**/*.ts', path.src + '**/*.tsx'])
.pipe(gulpTslint({
formatter: 'stylish',
program: program
}))
.pipe(gulpTslint.report({
emitError: true
}));
}
function copyJson() {
return gulp.src(path.src + '**/*.json')
.pipe(gulp.dest(path.dist))
.pipe(gulp.dest(path.example))
.pipe(gulp.dest(path.tool));
}
function copyDefinition() {
return gulp.src(path.src + '**/*.d.ts')
.pipe(gulp.dest(path.dist))
.pipe(gulp.dest(path.example))
.pipe(gulp.dest(path.tool));
}
function compileTs() {
var tsResult = tsProject.src()
.pipe(tsProject());
return tsResult
.pipe(gulp.dest(path.dist))
.pipe(gulp.dest(path.example))
.pipe(gulp.dest(path.tool));
}
exports.clean = clean;
exports.minifyImage = minifyImage;
exports.lintTs = lintTs;
exports.copyJson = copyJson;
exports.compileTs = compileTs;
exports.copyDefinition = copyDefinition;
exports.build = gulp.series(
lintTs,
clean,
compileTs,
gulp.parallel(minifyImage, copyJson),
);
exports.default = exports.build;