-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
85 lines (63 loc) · 1.87 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
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var del = require('del');
var _ = require('lodash');
var fs = require('fs');
var defaults = require('./server/conf/defaults');
var git = require('gulp-git');
var shell = require('gulp-shell');
// load all tasks in tasks directory
require('require-dir')('./tasks');
var settings = defaults;
var gitHash;
// TODO use gulp-changed
// TODO get livereload working with https://github.com/mollerse/gulp-embedlr
//gulp.task('watch', function () {
// // TODO do this instead of middleware to simplify the codebase (but complicate the build)
//});
gulp.task('clean', function (callback) {
del([
'dist',
'.tmp'
], callback);
});
gulp.task('git-hash', function(callback){
return git.revParse(
{
args:'--short HEAD'
},
function(err,hash){
gitHash = hash;
callback();
});
});
gulp.task('setVariables', ['git-hash'], function(){
});
gulp.task('build', ['git-hash', 'setVariables', 'images', 'fonts', 'views', 'translations']);
// alias for now, but could be more in the future
gulp.task('lint', ['jshint']);
gulp.task('test', ['lint', 'tests']);
gulp.task('rebuild-db', ['clean-db', 'build-db']);
gulp.task('clean-db', [], shell.task("node server/migrations/clean"));
gulp.task('build-db', [], shell.task("node server/migrations/reseed"));
gulp.task('server', ['build'], function (callback) {
var fork = require('child_process').fork;
var open = require('open');
var env = _.clone(process.env);
env.NODE_ENV = 'development';
var child = fork(__dirname + '/server.js', [], {
env: env
});
child.on('message', function (m) {
if (m.started) {
gutil.log('Opening ' + m.url);
open(m.url);
}
});
child.on('error', callback);
child.on('exit', function () {
callback(null);
});
});
gulp.task('default', ['build']);