Newer
Older
/*jshint esversion:6*/
const gulp = require('gulp');
const jshint = require('gulp-jshint');
const shell = require('gulp-shell');
const mocha = require('gulp-mocha');
const istanbul = require('gulp-istanbul');
const app_state = (process.env.NODE_ENV || 'development').trim().toLowerCase();
//dev config
var dev_config_file = './config.js';
//var config = require(configFile);
// define the default task and add the watch task to it
gulp.task('default', ['run','watch']);
// configure the jshint task
gulp.task('jshint', function() {
return gulp.src([js_files, "!node_modules/**/*.js", "!coverage/*"])
.pipe(jshint({
"esversion": 6
}))
.pipe(jshint.reporter('jshint-stylish'));
});
// configure which files to watch and what tasks to use on file changes
gulp.task('watch', function() {
gulp.watch(js_files/*, ['jshint']*/);
});
gulp.task('run', function(){
return gulp.src("*")
.pipe(shell('npm start'));
});
//Run as a user with CREATE permission and permission to create users on postgresql
gulp.task('create_database_test', function(){
var config = require(test_config_file);
.pipe(shell("yes | ./database/create_database.sh " + config.db_config.database))
.pipe(shell("yes | ./database/create_user.sh " + config.db_config.user + " " + config.db_config.password + " " + config.db_config.database ));
});
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
gulp.task('pre-test', () => {
return gulp.src(['src/**/*.js'])
.pipe(istanbul({includeUntested: true}))
.pipe(istanbul.hookRequire());
});
gulp.task('test',['create_database_test','pre-test'], function(){
gulp.src(['test/**/*.js'], {read: false})
.pipe(mocha({timeout: 60000}))
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({
thresholds: {
global: {
statements: 80,
branches: 70,
lines: 80,
functions: 80
}
}
}))
.on('error', () => {
process.exit(1);
})
.on('end', () => {
process.exit();
});
// return gulp.src(['test/*.js'])
// .pipe(mocha({
// reporter : 'spec'
// }));
});
module.exports = gulp;