1 | 'use strict';
|
2 |
|
3 | var gulp = require('gulp'),
|
4 | jshint = require('gulp-jshint'),
|
5 | stylish = require('jshint-stylish'),
|
6 | gutil = require('gulp-util'),
|
7 | mocha = require('gulp-mocha'),
|
8 | shrinkwrap = require('gulp-shrinkwrap'),
|
9 | nicePackage = require('gulp-nice-package');
|
10 |
|
11 | require('gulp-help')(gulp);
|
12 |
|
13 | function errorLogger(err) {
|
14 | gutil.beep();
|
15 | gutil.log(err.message);
|
16 | }
|
17 |
|
18 | function lint() {
|
19 | return gulp.src([
|
20 | './*.js',
|
21 | './test/**/*.js'
|
22 | ])
|
23 | .pipe(jshint('./lint/.jshintrc'))
|
24 | .pipe(jshint.reporter(stylish))
|
25 | .pipe(jshint.reporter('fail'))
|
26 | .on('error', errorLogger);
|
27 | }
|
28 |
|
29 | function test() {
|
30 | return gulp.src([
|
31 | './test/**/*.js',
|
32 | '!./test/helper/**'
|
33 | ])
|
34 | .pipe(mocha({reporter: 'dot'}))
|
35 | .on('error', errorLogger);
|
36 | }
|
37 |
|
38 | gulp.task('lint', function () {
|
39 | return lint();
|
40 | });
|
41 |
|
42 | gulp.task('test', ['lint'], function () {
|
43 | return test();
|
44 | });
|
45 |
|
46 |
|
47 | gulp.task('lint-watch', false, function () {
|
48 | lint();
|
49 | });
|
50 |
|
51 | gulp.task('test-watch', false, ['lint-watch'], function () {
|
52 | test();
|
53 | });
|
54 |
|
55 | gulp.task('watch', function () {
|
56 | gulp.watch([
|
57 | './*.js',
|
58 | './test/**/*.js'
|
59 | ], ['test-watch']);
|
60 | });
|
61 |
|
62 | gulp.task('ci', 'Run all tests and lint.', ['test']);
|
63 |
|
64 | gulp.task('shrinkwrap', 'Cleans package.json deps and generates npm-shrinkwrap.json', function () {
|
65 | return gulp.src('package.json')
|
66 | .pipe(nicePackage())
|
67 | .pipe(shrinkwrap())
|
68 | .pipe(gulp.dest('./'));
|
69 | }); |
\ | No newline at end of file |