forked from Campaign-Data-Visualization/campaign-cents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
77 lines (64 loc) · 1.99 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
"user strict";
var gulp = require('gulp'),
bower = require('gulp-bower'),
jshint = require('gulp-jshint'),
refresh = require('gulp-livereload'),
notify = require('gulp-notify'),
plumber = require('gulp-plumber'),
client = require('tiny-lr')(),
run = require('gulp-run'),
nodemon = require('gulp-nodemon'),
lr_port = 35728;
var paths = {
scripts: ['!client/lib/**/*.js', 'client/**/*.js'],
views: ['!client/lib/*.html', 'client/**/*.html', 'client/index.html']
};
var build = ['lint'];
gulp.task('bowerInstall', function () {
bower()
.pipe();
});
gulp.task('html', function () {
return gulp.src(paths.views)
.pipe(plumber())
.pipe(refresh(client))
//.pipe(notify({message: 'Views refreshed'}));
});
gulp.task('lint', function () {
return gulp.src(paths.scripts)
.pipe(plumber())
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(refresh(client))
//.pipe(notify({message: 'Lint done'}));
});
gulp.task('serve', function () {
nodemon({script: './server.js', ignore: ['node_modules/**/*.js']})
.on('restart', function () {
refresh(client);
});
});
gulp.task('live', function () {
client.listen(lr_port, function (err) {
if (err) {
return console.error(err);
}
});
});
gulp.task('watch', function () {
gulp.watch(paths.views, ['html']);
gulp.watch(paths.scripts, ['lint']);
});
gulp.task('database', function() {
var dir = 'backend/sql/'
var tables = ['candidates', 'koch_contribs', 'koch_orgs', 'leadership_pacs', 'states', 'zipcode'];
var live_tables = ['content', 'koch_assets'];
tables.forEach(function(t) {
console.log("Dumping "+t+" table...");
run('mysqldump -u root kochtracker '+t+' > '+dir+t+'.sql').exec()
});
console.log("Dumping schema....");
run('mysqldump -d -u root kochtracker '+tables.join(' ') +' '+ live_tables.join(' ')+ '> '+dir+'schema.sql' ).exec()
})
gulp.task('build', build);
gulp.task('default', ['build', 'live', 'serve', 'watch']);