-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
gulpfile.js
30 lines (26 loc) · 920 Bytes
/
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
var gulp = require('gulp')
, mongoose = require('mongoose')
, $ = require('gulp-load-plugins')()
, parseArgs = require('minimist')
gulp.task('default', ['test', 'jshint'])
gulp.task('test', ['dropdb'], function () {
return gulp.src('./test/**/*.js')
.pipe($.mocha({reporter: 'spec', timeout: 10000}))
.pipe($.exit())
})
gulp.task('dropdb', function (cb) {
var dbUrl = process.env.TEST_DB = parseArgs(process.argv)['db']
if (!dbUrl) return cb(new Error('Connection string must be specified via --db'));
mongoose.connect(dbUrl, function (err) {
if (err) return cb(err)
mongoose.connection.db.dropDatabase(function (err) {
if (err) return cb(err)
mongoose.disconnect(cb)
})
})
})
gulp.task('jshint', function () {
return gulp.src('./lib/**/*.js')
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
})