forked from Kononnable/typeorm-model-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
76 lines (65 loc) · 2.42 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
const gulp = require('gulp')
const ts = require("gulp-typescript");
const sourcemaps = require("gulp-sourcemaps");
const clean = require("gulp-clean");
const shell = require('gulp-shell');
const istanbul = require('gulp-istanbul');
const mocha = require('gulp-mocha');
const remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');
gulp.task('compile', ['clean'], function () {
var tsProject = ts.createProject('tsconfig.json');
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'))
});
gulp.task('clean', function () {
return gulp.src(['dist','coverage','output'], { read: false })
.pipe(clean());
});
gulp.task('prettier', function () {
return gulp.src('.prettierrc')
.pipe(shell(['prettier ./src/**/*.ts --write']))
// .pipe(shell(['prettier ./test/**/*.ts --write']))
});
gulp.task('pre-commit', ['prettier'], function () {
return gulp.src('package.json', { read: false })
.pipe(shell(['git update-index --again']))
})
gulp.task('watch', function () {
gulp.src('tsconfig.json')
.pipe(shell(['tsc -w']))
var watcher = gulp.watch(['src/**/*.ts', 'test/**/*.ts']);
watcher.on('change', function (changeInfo) {
console.log('File ' + changeInfo.path + ' was ' + changeInfo.type + '.');
if (changeInfo.type == 'deleted') {
let jsFilePath = changeInfo.path
.split('.ts').join('.js')
.split('\\').join('/')
.split('/src/').join('/dist/src/')
.split('/test/').join('/dist/test/');
return gulp.src([jsFilePath, jsFilePath + '.map'], { read: false })
.pipe(clean());
}
});
})
gulp.task('pre-test', function () {
return gulp.src(['dist/src/**/*.js'])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
gulp.task('test', ['pre-test'], function () {
return gulp.src(['dist/test/**/*.test.js'], { read: false })
.pipe(mocha())
.pipe(istanbul.writeReports())
});
gulp.task('test-coverage', ['test'], function () {
var GulpStream = gulp.src('coverage/coverage-final.json')
.pipe(remapIstanbul())
.pipe(gulp.dest('coverage/remapped'));
if ((process.env.CI == 'true')) {
GulpStream = GulpStream.pipe(shell(['codecov --file=./coverage/remapped/coverage-final.json ']));
}
return GulpStream;
})