2 Copyright (C) 2014 Yusuke Suzuki <utatane.tea@gmail.com>
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
13 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
14 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 var gulp = require('gulp');
28 var mocha = require('gulp-mocha');
29 var jshint = require('gulp-jshint');
30 var eslint = require('gulp-eslint');
31 var istanbul = require('gulp-istanbul');
32 var bump = require('gulp-bump');
33 var filter = require('gulp-filter');
34 var git = require('gulp-git');
35 var tagVersion = require('gulp-tag-version');
37 var SRC = [ 'lib/*.js' ];
39 var TEST = [ 'test/*.js' ];
49 'no-use-before-define': 0,
50 'no-underscore-dangle': 0,
52 'no-constant-condition': 0,
54 'dot-notation': [2, {'allowKeywords': false}]
61 gulp.task('test', function (cb) {
63 .pipe(istanbul()) // Covering files
64 .on('finish', function () {
68 timeout: 100000 // 100s
70 .pipe(istanbul.writeReports()) // Creating the reports after tests runned
75 gulp.task('lint', function () {
77 .pipe(jshint('.jshintrc'))
78 .pipe(jshint.reporter(require('jshint-stylish')))
79 .pipe(jshint.reporter('fail'))
80 .pipe(eslint(ESLINT_OPTION))
81 .pipe(eslint.formatEach('compact', process.stderr))
82 .pipe(eslint.failOnError());
87 * Bumping version number and tagging the repository with it.
88 * Please read http://semver.org/
90 * You can use the commands
92 * gulp patch # makes v0.1.0 -> v0.1.1
93 * gulp feature # makes v0.1.1 -> v0.2.0
94 * gulp release # makes v0.2.1 -> v1.0.0
96 * To bump the version numbers accordingly after you did a patch,
97 * introduced a feature or made a backwards-incompatible release.
100 function inc(importance) {
101 // get all the files to bump version in
102 return gulp.src(['./package.json'])
103 // bump the version number in those files
104 .pipe(bump({type: importance}))
105 // save it back to filesystem
106 .pipe(gulp.dest('./'))
107 // commit the changed version number
108 .pipe(git.commit('Bumps package version'))
109 // read only one file to get the version number
110 .pipe(filter('package.json'))
111 // **tag it in the repository**
112 .pipe(tagVersion({ prefix: '' }));
115 gulp.task('patch', [ 'travis' ], function () { return inc('patch'); });
116 gulp.task('minor', [ 'travis' ], function () { return inc('minor'); });
117 gulp.task('major', [ 'travis' ], function () { return inc('major'); });
119 gulp.task('travis', [ 'lint', 'test' ]);
120 gulp.task('default', [ 'travis' ]);