1 | 'use strict';
|
2 | var gulp = require('gulp');
|
3 | var mocha = require('gulp-mocha');
|
4 | var ts = require('gulp-typescript');
|
5 | var concat = require('gulp-concat');
|
6 | var sourcemaps = require('gulp-sourcemaps');
|
7 | var tsProject = ts.createProject('tsconfig.json');
|
8 | var spawn = require('child_process').spawn;
|
9 | var bump = require('gulp-bump');
|
10 |
|
11 | var prompt = require('gulp-prompt');
|
12 | var git = require('gulp-git');
|
13 |
|
14 | gulp.task('quickpatch', ['pushPatch'], function (done) {
|
15 | spawn('npm', ['publish'], { stdio: 'inherit' }).on('close', done);
|
16 | });
|
17 |
|
18 | gulp.task('bumpPatch', function () {
|
19 | return gulp.src('./package.json').pipe(bump({
|
20 | type: 'patch'
|
21 | })).pipe(gulp.dest('./'));
|
22 | });
|
23 |
|
24 |
|
25 | gulp.task('Addbumped', ['bumpPatch'], function () {
|
26 | return gulp.src('.').pipe(git.add({ args: '-A' }));
|
27 | });
|
28 | gulp.task('pushPatch', ['Addbumped'], function () {
|
29 | return gulp.src('.').pipe(prompt.prompt({
|
30 | type: 'input',
|
31 | name: 'commit',
|
32 | message: 'enter a commit msg, eg initial commit'
|
33 | }, function (res) {
|
34 | return gulp.src('.').pipe(git.commit(res.commit)).on('end', function () {
|
35 | git.push()
|
36 | });;
|
37 | }));
|
38 | });
|
39 |
|
40 | gulp.task('test', function (done) {
|
41 | return gulp.src('test/**/*.js', { read: false })
|
42 | .pipe(mocha({ reporter: 'spec' }).on('error', function (err) {
|
43 | throw err;
|
44 | }).on('close', function () {
|
45 | process.exit(-1);
|
46 | }));
|
47 | });
|
48 |
|
49 | gulp.task('build', function () {
|
50 | var tsResult = tsProject.src()
|
51 | .pipe(sourcemaps.init())
|
52 |
|
53 | .pipe(ts(tsProject, {
|
54 | sortOutput: true,
|
55 | }));
|
56 |
|
57 | return tsResult
|
58 | .pipe(sourcemaps.write())
|
59 | .pipe(gulp.dest('.'));
|
60 | }); |
\ | No newline at end of file |