-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
70 lines (64 loc) · 1.56 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
const eslint = require('gulp-eslint');
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const prettier = require('gulp-prettier');
const sourcemaps = require('gulp-sourcemaps');
const ts = require('gulp-typescript');
const tsProject = ts.createProject('tsconfig.json');
// for fast exit
gulp.on('stop', () => {
process.exit(0);
});
gulp.on('err', () => {
process.exit(1);
});
// tsc
gulp.task('tsc', () => {
return gulp
.src(['*.ts', 'bin/*.ts', 'test/*.ts'], {base: '.'})
.pipe(tsProject())
.js.pipe(gulp.dest('.'));
});
gulp.task('tsc-test', () => {
return gulp
.src(['*.ts', 'bin/*.ts', 'test/*.ts'], {base: '.'})
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(sourcemaps.write())
.pipe(gulp.dest('.'));
});
// lint
gulp.task('lint', () => {
return gulp
.src(['*.ts', 'bin/*.ts', 'test/*.ts'])
.pipe(eslint({useEslintrc: true}))
.pipe(eslint.format());
});
// format
gulp.task('format', () => {
return gulp
.src(['*.ts', 'bin/*.ts', 'test/*.ts'], {base: '.'})
.pipe(
prettier({
parser: 'typescript',
arrowParens: 'always',
bracketSpacing: false,
insertPragma: false,
printWidth: 120,
proseWrap: 'preserve',
requirePragma: false,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
useTabs: false,
})
)
.pipe(gulp.dest('.'));
});
// test
gulp.task('test', ['tsc-test'], () => {
return gulp
.src(['test/*.js'], {base: '.'})
.pipe(mocha({reporter: 'nyan'}));
});