Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
158 lines (141 loc) · 4.68 KB
/
Copy pathgulpfile.js
File metadata and controls
158 lines (141 loc) · 4.68 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
(function () {
"use strict";
var gulp = require("gulp"),
nodemon = require("gulp-nodemon"),
browserSync = require("browser-sync"),
env = require('gulp-env'),
jshint = require('gulp-jshint'),
gulpMocha = require('gulp-mocha'),
gutil = require('gutil'),
util = require('gulp-util'),
istanbul = require('gulp-istanbul'),
serverWatchFiles = [
'server.js',
'cluster.js',
'app.js',
'lib/auth/**/*.js',
'lib/configs/**/*.js',
'lib/controllers/**/*.js',
'lib/data/**/*.js',
'lib/handlers/**/*.js',
'lib/helpers/**/*.js',
'lib/middlewares/**/*.js',
'lib/models/**/*.js',
'lib/routes/**/*.js',
'lib/views/**/*.hbs',
'lib/securityconfigs/**/*.js'
],
clientWatchFiles = [
'lib/views/**/*.*',
'public/**/*.css',
'adminapp/**/*.js'
];
gulp.task("default", ["nodemon"], function () {
});
gulp.task("copy-html", function () {
return gulp.src(['app/**/**.html', 'app/**/**.css'])
.pipe(gulp.dest('app/build'));
});
gulp.task("browser-sync", function () {
browserSync({
proxy: "http://localhost:3000",
files: clientWatchFiles,
port: 7000,
browser: ["google-chrome"]
});
});
gulp.task('nodemon', function (cb) {
var called = false;
return nodemon({
// nodemon our expressjs server
script: 'cluster.js',
ignore: [
'gulpfile.js',
'node_modules/**',
'public/uploads/**',
'public/lib/**'
],
// watch core server file(s) that require server restart on change
watch: serverWatchFiles
})
.on('start', function onStart() {
// ensure start only got called once
if (!called) {
cb();
called = true;
}
})
.on('restart', function onRestart() {
browserSync.reload();
});
});
gulp.task("watch:clientFiles", function () {
browserSync.watch(clientWatchFiles).on('change', function () {
browserSync.reload();
});
});
gulp.task("watch:js", function () {
browserSync.watch('public/js/*.js').on('change', function () {
browserSync.reload();
});
});
gulp.task('lint', function () {
gulp.src('./**/*.js')
.pipe(jshint());
});
// gulp.task('test', ['pre-test'], function(){
gulp.task('test', function () {
env({
vars: {
ENV: 'Test'
}
});
return gulp.src('./test/index.js', {read: false})
.pipe(gulpMocha({reporter: 'spec'}))
// Creating the reports after tests ran
.pipe(istanbul.writeReports({
dir: './public/assets/coverage',
reporters: ['lcov'],
reportOpts: {dir: './public/assets/coverage'}
}))
// Enforce a coverage of at least 90%
.pipe(istanbul.enforceThresholds({thresholds: {global: 70}}))
.on('error', util.log, function () {
process.exit(1);
})
.once('end', function () {
process.exit();
});
});
gulp.task('unit_test', function () {
env({
vars: {
ENV: 'Test'
}
});
return gulp.src('./test/unittests/*.js', {read: false})
.pipe(gulpMocha({reporter: 'spec'}))
// Creating the reports after tests ran
.pipe(istanbul.writeReports({
dir: './assets/coverage',
reporters: ['lcov'],
reportOpts: {dir: './assets/coverage'}
}))
// Enforce a coverage of at least 90%
.pipe(istanbul.enforceThresholds({thresholds: {global: 90}}))
.on('error', util.log, function () {
process.exit(1);
})
.once('end', function () {
process.exit();
});
});
gulp.task('pre-test', function () {
// This tells gulp which files you want to pipe
// In our case we want to pipe every `.js` file inside any folders inside `test`
return gulp.src('test/integrationtests/*.js')
.pipe(istanbul())
// This overwrites `require` so it returns covered files
.pipe(istanbul.hookRequire());
});
})();