forked from ditup/ditapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
71 lines (62 loc) · 1.96 KB
/
gulpfile.js
File metadata and controls
71 lines (62 loc) · 1.96 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
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
const gulp = require('gulp'),
spawn = require('child_process').spawn,
// exec = require('child_process').exec,
eslint = require('gulp-eslint');
let node,
oauth;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
*/
gulp.task('server', ['oauth'], function() {
if (node) node.kill();
node = spawn('node', ['bin/www'],
{ stdio: 'inherit' });
node.on('close', function (code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
});
gulp.task('oauth', function() {
if (oauth) oauth.kill();
oauth = spawn('node', ['../oauth2orize/examples/all-grants/app.js'],
{ stdio: 'inherit' });
oauth.on('close', function (code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
});
/**
* $ gulp
* description: start the development environment
*/
gulp.task('default', function() {
gulp.run('server');
gulp.watch(['./app.js', './routes/**/*.js'], function() {
gulp.run('server');
});
// Need to watch for sass changes too? Just add another watch call!
// no more messing around with grunt-concurrent or the like. Gulp is
// async by default.
});
// clean up if an error goes unhandled.
process.on('exit', function() {
if (node) node.kill();
if (oauth) oauth.kill();
});
gulp.task('eslint', function() {
return gulp.src(['./**/*.js', '!./node_modules/**']).pipe(eslint())
.pipe(eslint.format());
// Brick on failure to be super strict
// .pipe(eslint.failOnError());
});
gulp.task('eslint:fix', function() {
return gulp.src(['./**/*.js', '!./node_modules/**'])
.pipe(eslint({ fix: true }))
.pipe(eslint.format());
});