-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
86 lines (65 loc) · 2.03 KB
/
Copy pathgulpfile.js
File metadata and controls
86 lines (65 loc) · 2.03 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
'use strict';
require('app-module-path').addPath(__dirname);
const gulp = require('gulp');
const exec = require('child_process').execSync;
const $ = require('gulp-load-plugins')();
const stylish = require('jshint-stylish');
const watchify = require('watchify');
const minimist = require('minimist');
const serverRunner = require('server');
const testRunner = require('test/test');
const knownOptions = {
string: 'params',
"default": {
params: ''
}
};
const options = minimist(process.argv.slice(2), knownOptions);
require('./config/init')();
const config = require('./config/config');
const sources = {
server: {
views: ['app/views/**/*.*'],
js: ['runner.js', 'migrate-db.js', 'server.js', 'tools.js', 'config/**/*.js', 'app/**/*.js', 'migrations/**/*.js']
}
};
const debugPort = process.env.DEBUG_PORT || 5858;
gulp.task('jshint', function () {
return gulp.src(sources.server.js)
.pipe($.plumber())
.pipe($.jshint())
.pipe($.jshint.reporter(stylish));
});
gulp.task('lint', ['jshint']);
gulp.task('watch', [], function () {
var readDelay;
readDelay = 2000;
$.nodemon({
script: 'runner.js',
args: ['server'],
ext: 'js',
nodeArgs: ['--inspect=' + debugPort],
watch: sources.server.js.concat(sources.server.views)
}).on('change', ['jshint']);
return gulp.watch(sources.server.views.concat(sources.server.js), {
debounceDelay: readDelay
}, ['jshint']);
});
gulp.task('tool', function () {
return exec('node runner.js tools.js ' + options.params, {stdio:[0,1,2]});
});
gulp.task('migrate', function () {
return require('migrate-db')(options.params);
});
gulp.task('test', function () {
if (process.env.NODE_ENV !== 'test') {
throw new Error('Wrong NODE_ENV value. Tests must be run with "test"');
}
return testRunner(options.params);
});
gulp.task('install', ['migrate']);
gulp.task('run', function (callback) {
return serverRunner(options.params, callback);
});
gulp.task('dev', ['watch']);
gulp.task('default', [process.env.NODE_ENV === 'production' ? 'run' : 'dev']);