UNPKG

1.47 kBJavaScriptView Raw
1'use strict';
2
3var 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
11require('gulp-help')(gulp);
12
13function errorLogger(err) {
14 gutil.beep();
15 gutil.log(err.message);
16}
17
18function 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
29function test() {
30 return gulp.src([
31 './test/**/*.js',
32 '!./test/helper/**'
33 ])
34 .pipe(mocha({reporter: 'dot'}))
35 .on('error', errorLogger);
36}
37
38gulp.task('lint', function () {
39 return lint();
40});
41
42gulp.task('test', ['lint'], function () {
43 return test();
44});
45
46// when watching, do NOT return the stream, otherwise watch won't continue on error
47gulp.task('lint-watch', false, function () {
48 lint();
49});
50
51gulp.task('test-watch', false, ['lint-watch'], function () {
52 test();
53});
54
55gulp.task('watch', function () {
56 gulp.watch([
57 './*.js',
58 './test/**/*.js'
59 ], ['test-watch']);
60});
61
62gulp.task('ci', 'Run all tests and lint.', ['test']);
63
64gulp.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