-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gulpfile.js
118 lines (99 loc) · 2.68 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
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
/* jshint node: true */
(function () {
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var jshint = require('gulp-jshint');
var jscs = require('gulp-jscs');
var shell = require('gulp-shell');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var coveralls = require('gulp-coveralls');
var env = require('gulp-env');
gulp.task('lint', function () {
return gulp.src([
'./build_scripts/**/*.js',
'./config/**/*.js',
'./models/**/*.js',
'./routes/**/*.js',
'./scrapers/**/*.js',
'./*.js',
])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jscs())
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'));
// .pipe(stylish.combineWithHintResults())
// .pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('scss', function () {
gulp.src('./public/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./public/css'));
});
gulp.task('scss:watch', function () {
gulp.watch('./public/scss/**/*.scss', ['scss']);
});
gulp.task('scrape', ['pcWarning', 'usWarning']);
gulp.task('pcWarning', shell.task([
'node scrapers/pcWarnings.js',
]));
gulp.task('usWarning', shell.task([
'node scrapers/usWarnings.js',
]));
gulp.task('build_db', shell.task([
'node build_scripts/build.js',
]));
gulp.task('set-test-env', function () {
env({
vars: {
NODE_ENV: 'test',
},
});
});
gulp.task('pre-mocha', ['set-test-env', 'scrape']);
gulp.task('mocha', ['pre-mocha'], function () {
return gulp
.src('tests/*.js', { read: false })
.pipe(mocha());
});
// Avoids scraping for when your internet is slow
gulp.task('mocha-min', ['set-test-env'], function () {
return gulp
.src('tests/*.js', { read: false })
.pipe(mocha());
});
gulp.task('mocha-nyan', ['pre-mocha'], function () {
return gulp
.src('tests/*.js', { read: false })
.pipe(mocha({ reporter: 'nyan' }));
});
gulp.task('pre-coveralls', function () {
return gulp.src([
'routes/**/*.js',
'app.js',
'scrapers/**/*.js',
'models/**/*.js',
'config/passport.js',
'config/access.js',
'config/countries.js',
])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
gulp.task('coverage', ['pre-mocha', 'pre-coveralls'], function () {
return gulp
.src('tests/*.js', { read: false })
.pipe(mocha({ reporter: 'spec' }))
.pipe(istanbul.writeReports());
});
gulp.task('coveralls', ['coverage'], function () {
return gulp
.src(__dirname + '/coverage/lcov.info')
.pipe(coveralls());
});
gulp.task('default', ['lint', 'scss', 'scss:watch']);
gulp.task('ci', ['lint', 'scss', 'coveralls']);
gulp.task('deploy', ['lint', 'scss', 'scrape']);
})();