-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (52 loc) · 1.75 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
var gulp = require('gulp');
var clean = require('gulp-clean');
var ts = require('gulp-typescript');
var mocha = require('gulp-mocha');
var spawn = require('child_process').spawn;
gulp.task('default', ['build']);
gulp.task('build', ['buildMain', 'buildTest']);
gulp.task('buildMain', ['clean'], () => {
var tsProject = ts.createProject('tsconfig.json');
var tsResult = gulp.src('src/main/**/*.ts').pipe(tsProject());
return tsResult.pipe(gulp.dest('build/main'));
});
gulp.task('buildTest', ['buildMain'], () => {
var tsProject = ts.createProject('tsconfig.json');
var tsResult = gulp.src('src/test/**/*.ts').pipe(tsProject());
return tsResult.pipe(gulp.dest('build/test'));
});
gulp.task('clean', () => {
return gulp.src(['build', 'express-ts-controller-*.tgz']).pipe(clean());
});
gulp.task('test', ['buildTest'], () => {
return gulp.src('build/test/specs/**/*.js')
.pipe(mocha());
});
gulp.task('pre-package', ['buildMain'], () => {
return gulp.src(['package.json', 'README.md']).pipe(gulp.dest('build/main'));
});
gulp.task('pack', ['pre-package'], (done) => {
console.log('');
let npm = spawn('npm', ['pack', './build/main']);
npm.stdout.on('data', (data) => {
process.stdout.write(data.toString());
});
npm.on('exit', (exitCode) => {
console.log('');
done(exitCode);
});
});
gulp.task('publish', ['pre-package'], (done) => {
console.log('');
let npm = spawn('npm', ['publish', './build/main']);
npm.stdout.on('data', (data) => {
process.stdout.write(data.toString());
});
npm.stderr.on('data', (data) => {
process.stdout.write(data.toString());
});
npm.on('exit', (exitCode) => {
console.log('');
done(exitCode);
});
});