-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
78 lines (64 loc) · 2.3 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
const gulp = require('gulp');
const gulp_ts = require('gulp-typescript');
const gulp_sourcemaps = require('gulp-sourcemaps');
const del = require('del');
const path = require('path');
const { execSync } = require('child_process');
const project = gulp_ts.createProject('tsconfig.json');
let _linter;
let _gulp_tslint;
let _tslint;
let _runSequence;
const runSequence = () => _runSequence = _runSequence || require('run-sequence');
const gulp_tslint = () => _gulp_tslint = _gulp_tslint || require('gulp-tslint');
const tslint = () => _tslint = _tslint || require('tslint');
const linter = () => _linter = _linter || tslint().Linter.createProgram('tsconfig.json');
gulp.task('default', ['build']);
gulp.task('build:vscode', cb => runSequence()('lint', 'build', cb));
gulp.task('gh-prebuild', cb => runSequence()('build', 'gh-prebuild-prepare', cb));
gulp.task('pause', cb => setTimeout(() => cb(), 1e3));
gulp.task('tests', cb => runSequence()('lint', 'build', 'pause', 'build:tests', cb));
gulp.task('lint', () => {
gulp.src('src/**/*.ts')
.pipe(gulp_tslint()({
configuration: 'tslint.json',
formatter: 'prose',
program: linter()
}))
.pipe(gulp_tslint().report());
})
gulp.task('build', () => {
del.sync(['bin/**/*.*']);
const tsCompile = gulp.src('src/**/*.ts')
.pipe(gulp_sourcemaps.init({ base: 'src' }))
.pipe(project());
tsCompile.pipe(gulp.dest('bin/'));
gulp.src('src/**/*.js').pipe(gulp.dest('bin/'));
gulp.src('src/**/*.json').pipe(gulp.dest('bin/'));
gulp.src('src/**/*.lang').pipe(gulp.dest('bin/'));
return tsCompile.js
.pipe(gulp_sourcemaps.write('.', { sourceRoot: '../src' }))
.pipe(gulp.dest('bin/'));
});
gulp.task('gh-prebuild-prepare', () => {
del.sync([
'../prebuild/**',
'../prebuild/.*',
'!../prebuild',
'!../prebuild/.git',
'!../prebuild/.git/**'
], { force: true });
gulp.src('bin/**/*.*').pipe(gulp.dest('../prebuild/bin'));
gulp.src('package.json').pipe(gulp.dest('../prebuild'));
})
gulp.task('build:tests', () => {
del.sync(['test/**/*.js']);
const tsCompile = gulp.src('test/**/*.ts')
.pipe(gulp_sourcemaps.init({ base: 'test' }))
.pipe(project());
tsCompile.pipe(gulp.dest('test/'));
return tsCompile.js
.pipe(gulp_sourcemaps.mapSources(sourcePath => path.join(__dirname, 'test', sourcePath)))
.pipe(gulp_sourcemaps.write())
.pipe(gulp.dest('test/'));
});