-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
70 lines (57 loc) · 1.61 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
var gulp = require('gulp'),
spawn = require('child_process').spawn,
fs = require('fs');
var server;
/**
* $ gulp server
* Launch the server in dev mode. If there's a server already running, kill it.
* Rebuild docs on start and file change.
*/
gulp.task('server', function() {
gulp.run('docs')
if (server) server.kill()
server = spawn('node', ['server.js', '--dev'], {stdio: 'inherit'})
server.on('close', function (code) {
if (code === 8) {
console.log('Error detected, waiting for changes...');
}
});
})
/**
* $ gulp test
* Run api tests via jasmine-node.
*/
gulp.task('test', function() {
server = spawn('jasmine-node', ['./tests/'], {stdio: 'inherit'})
})
/**
* $ gulp docs
* Create web documentation data
*/
gulp.task('docs', function() {
var outputFile = './api-documentation.json'
var stream = fs.createWriteStream(outputFile);
var docs = spawn('./docs/parse-docs.js', ['--file', 'server.js'])
docs.stdout.pipe(stream);
//docs.stderr.pipe(stream);
docs.on('close', function (code) {
console.log('Wrote API documentation JSON to: ' + outputFile);
fs.createReadStream(outputFile).pipe(
fs.createWriteStream('../ModelSEED-UI/app/views/docs/api-docs.json')
);
});
})
/**
* $ gulp
* Start the development environment
*/
gulp.task('default', function() {
gulp.run('server')
gulp.watch(['./server.js', './parsers/*.js', './docs/*.js'], function() {
gulp.run('server')
})
})
// clean up if an error goes unhandled.
process.on('exit', function() {
if (server) server.kill()
})