-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
53 lines (45 loc) · 1.16 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
require('shelljs/global');
const gulp = require('gulp');
/**
* Run eslint for javascript files
* @param done
*/
function eslintJs(done) {
const command = './node_modules/.bin/eslint ./src; exit 0';
const exitCode = exec(command).code;
if (exitCode === 0) {
done();
} else {
console.log('ESLINT found Errors. Continuing...');
done();
}
}
/**
* Run unit tests using the mocha test runner
* @param done
*/
function mochaTest(done) {
const command = 'NODE_ENV=test ./node_modules/mocha/bin/mocha --reporter spec --timeout 15000 test/**/*.test.js';
const exitCode = exec(command).code;
if (exitCode === 0) {
done();
} else {
done('Unit tests failed');
}
}
/**
* Start the express app
* @param done
*/
function startServer(done) {
const command = 'NODE_ENV=development ./node_modules/.bin/nodemon ./src/app.js';
exec(command);
done();
}
// Gulp Wireup
gulp.task('serve', startServer);
gulp.task('lint::js', eslintJs);
gulp.task('test::mocha', mochaTest);
gulp.task('test::unit', gulp.parallel('lint::js', 'test::mocha'));
gulp.task('test', gulp.series('test::unit'));