2014-10-13 21:14:51 +00:00
|
|
|
var gulp = require('gulp'),
|
2014-12-22 21:38:48 +00:00
|
|
|
debug = require('debug')('freecc:gulp'),
|
|
|
|
bower = require('bower-main-files'),
|
|
|
|
nodemon = require('gulp-nodemon'),
|
|
|
|
sync = require('browser-sync'),
|
|
|
|
reload = sync.reload,
|
|
|
|
inject = require('gulp-inject'),
|
2015-01-25 20:22:21 +00:00
|
|
|
reloadDelay = 1000;
|
2014-10-13 21:14:51 +00:00
|
|
|
|
2014-12-22 21:38:48 +00:00
|
|
|
var paths = {
|
|
|
|
server: './app.js',
|
2014-12-23 16:48:28 +00:00
|
|
|
serverIgnore: []
|
|
|
|
};
|
|
|
|
|
2014-10-13 21:14:51 +00:00
|
|
|
gulp.task('inject', function() {
|
|
|
|
gulp.src('views/home.jade')
|
|
|
|
.pipe(inject(gulp.src(bower()), {
|
|
|
|
//ignorePath: '/public'
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('views'));
|
|
|
|
});
|
|
|
|
|
2014-12-22 21:38:48 +00:00
|
|
|
gulp.task('serve', function(cb) {
|
|
|
|
var called = false;
|
|
|
|
nodemon({
|
|
|
|
script: paths.server,
|
|
|
|
ext: '.js',
|
|
|
|
ignore: paths.serverIgnore,
|
|
|
|
env: {
|
|
|
|
'NODE_ENV': 'development',
|
|
|
|
'DEBUG': 'freecc:*'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.on('start', function() {
|
|
|
|
if (!called) {
|
|
|
|
called = true;
|
|
|
|
setTimeout(function() {
|
|
|
|
cb();
|
|
|
|
}, reloadDelay);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.on('restart', function(files) {
|
|
|
|
if (files) {
|
|
|
|
debug('Files that changes: ', files);
|
|
|
|
}
|
|
|
|
setTimeout(function() {
|
|
|
|
debug('Restarting browsers');
|
|
|
|
reload();
|
|
|
|
}, reloadDelay);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('sync', ['serve'], function() {
|
|
|
|
sync.init(null, {
|
2014-12-23 16:48:28 +00:00
|
|
|
proxy: 'http://localhost:3000',
|
|
|
|
logLeval: 'debug',
|
|
|
|
files: ['public/**/*'],
|
|
|
|
port: 3001,
|
|
|
|
open: true,
|
|
|
|
reloadDelay: reloadDelay
|
2014-12-22 21:38:48 +00:00
|
|
|
});
|
|
|
|
});
|
2014-10-13 21:14:51 +00:00
|
|
|
|
2014-12-22 21:38:48 +00:00
|
|
|
gulp.task('default', ['serve', 'sync']);
|