-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
64 lines (56 loc) · 1.53 KB
/
gulpfile.js
File metadata and controls
64 lines (56 loc) · 1.53 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const Promise = require('bluebird');
const getSqlConnection = require('./config/connection').getSqlConnection;
const yargs = require('yargs');
const mocha = require('gulp-mocha');
const seed = require('./lib/seed');
const c = require('./lib/constants/utils');
gulp.task('eslint', () => {
var stream = gulp.src(['**/*.js', '!node_modules/**', '!coverage/**', '!docs/**'])
.pipe(eslint({
quiet: true,
globals: [
'describe',
'it',
'beforeEach',
'afterEach'
]
}))
.pipe(eslint.format());
if (yargs.argv.failTaskOnError) {
stream = stream.pipe(eslint.failAfterError());
}
return stream;
});
gulp.task('test', () => {
var stream = gulp.src('test/**/**.js', {read: false})
.pipe(mocha({reporter: 'spec', timeout: 5000})
.on('error', function(err) {
console.log(err.toString());
}));
stream.on('end', function() {
Promise.using(getSqlConnection(), function(connection) {
connection.destroy();
});
});
if (yargs.argv.failTaskOnError) {
stream = stream.on('error', process.exit.bind(process, 1));
} else {
stream = stream.on('error', process.exit.bind(process, 0));
}
return stream;
});
gulp.task('seed', () => {
var seedType = yargs.argv.demo ? c.DEMO : c.TEST;
if (yargs.argv.auth0) {
if (seedType == c.DEMO) {
return seed.demoSeed();
} else {
return seed.testSeed();
}
} else {
return seed.dbSeed(seedType);
}
});