-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
69 lines (54 loc) · 1.77 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
var Qb = require('./lib')
, fs = require('fs')
, gulp = require('gulp')
, mocha = require('gulp-mocha')
, gutil = require('gulp-util')
, jshint = require('gulp-jshint')
, stylish = require('jshint-stylish')
, nodemon = require('gulp-nodemon')
, source = require('vinyl-source-stream')
, browserify = require('browserify')
, definitions = require('./example-definitions');
// Lint.
gulp.task('lint', function() {
return gulp.src(['./lib/*.js'])
.pipe(jshint({}))
.pipe(jshint.reporter(stylish));
});
// Test.
gulp.task('test', ['lint'], function () {
return gulp.src('test/*.test.js', { read: false })
.pipe(mocha({reporter: 'spec'}))
.on('error', function(err) { return gutil.log(err.stack || err.message); });
});
// Retest on change.
gulp.task('watch-test', function() {
gulp.watch(['qb.js', 'test/*.test.js'], ['test']);
});
// Start API.
gulp.task('start', function() {
nodemon({ script: 'example-api/app.js', ignore: ['node_modules/'] });
});
// Create cached schema for use without Node server.
gulp.task('cache', function() {
var qb = new Qb(definitions);
var schema = JSON.stringify(qb.schema, null, 1);
fs.writeFileSync('./example-app/cached-schema.json', schema);
});
// Browserify example-app/app.js
gulp.task('bundle', function() {
return browserify({ debug: true })
.transform('jadeify')
.add('./example-app/app.js')
.bundle()
.on('error', function(err) {
gutil.log('Browserify error:', new Error(err));
this.emit('end');
})
.pipe(source('bundle.js'))
.pipe(gulp.dest('./example-app'));
});
// Rebundle on change.
gulp.task('watch', ['bundle'], function() {
gulp.watch(['./example-app/app.js', './example-app/templates/*'], ['bundle']);
});