-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
98 lines (87 loc) · 2.41 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
const gulp = require('gulp'),
clean = require('gulp-clean'),
gulpCopy = require('gulp-copy'),
ts = require('gulp-typescript'),
sourcemaps = require('gulp-sourcemaps'),
nodemon = require('gulp-nodemon'),
tslint = require("gulp-tslint"),
mocha = require('gulp-mocha'),
env = require('gulp-env'),
shell = require('gulp-shell');
gulp.task('clean', () => {
return gulp.src('dist', { read: false })
.pipe(clean());
});
gulp.task('clean-node', () => {
return gulp.src('node_modules', { read: false })
.pipe(clean());
});
gulp.task('copy', ['clean'], () => {
return gulp.src([ 'src/assets/**/*' ])
.pipe(gulpCopy('dist'));
});
gulp.task('build', ['clean', 'copy'], () => {
const tsconfig = ts.createProject('tsconfig.json');
const tsResult = tsconfig.src()
.pipe(tsconfig())
return tsResult.js
.pipe(gulp.dest('dist'))
});
gulp.task('build-dev', ['clean', 'copy'], () => {
const tsconfig = ts.createProject('tsconfig.json');
const tsResult = tsconfig.src()
.pipe(sourcemaps.init())
.pipe(tsconfig());
return tsResult.js
.pipe(sourcemaps.mapSources(function(sourcePath, file) {
return '../../src/' + sourcePath;
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'))
});
gulp.task('test', ['build'], () => {
const envs = env.set({ NODE_ENV: 'test' });
return gulp.src('dist/test/**/*.test.js', { read: false })
.pipe(mocha({
reporter: 'dot',
timeout: 500,
}))
.once('error', () => { process.exit(1); })
.once('end', () => { process.exit(); });
});
gulp.task('test-dev', ['build-dev'], () => {
const envs = env.set({ NODE_ENV: 'test' });
return gulp.src('dist/test/**/*.test.js', { read: false })
.pipe(mocha({
reporter: 'dot',
timeout: 500,
}));
});
gulp.task("tslint", () => {
gulp.src([
'src/**/*.ts',
'test/**/*.test.ts'
])
.pipe(tslint({
formatter: "prose"
}))
.pipe(tslint.report({
emitError: false,
reportLimit: 5,
}));
});
gulp.task('watch', ['build-dev'], () => {
gulp.watch(
['src/**/*.ts', 'test/**/*.test.ts'],
['build-dev', 'tslint', 'test-dev']
);
});
gulp.task('demon', () => {
nodemon({
script: 'dist/src/server.js',
watch: '**/dist/**/*',
ext: 'js',
env: { DEBUG: '' }, // set DEBUG: '*' to enable verbose mode
delay: 100
});
});