forked from jsdoc/jsdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
82 lines (70 loc) · 2.09 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
/*eslint max-nested-callbacks: 0 */
'use strict';
var eslint = require('gulp-eslint');
var exec = require('child_process').exec;
var gulp = require('gulp');
var istanbul = require('istanbul');
var jsonEditor = require('gulp-json-editor');
var os = require('os');
var path = require('path');
var util = require('util');
function execCb(cb, err, stdout, stderr) {
console.log(stdout);
console.error(stderr);
cb(err);
}
var options = {
coveragePaths: [
'*.js',
'lib/**/*.js',
'plugins/*.js'
],
lintPaths: [
'*.js',
'lib/**/*.js',
'plugins/*.js',
'templates/default/*.js',
'templates/haruki/*.js',
'test/specs/**/*.js'
],
nodeBin: path.resolve(__dirname, './jsdoc.js'),
nodePath: process.execPath,
rhinoBin: (function() {
var filepath = path.resolve(__dirname, './jsdoc');
if (os.platform().indexOf('win') === 0) {
filepath += '.cmd';
}
return filepath;
})()
};
gulp.task('bump', function() {
gulp.src('./package.json')
.pipe(jsonEditor({
revision: String( Date.now() )
}))
.pipe(gulp.dest('./'));
});
gulp.task('coverage', function(cb) {
var cmd = util.format('./node_modules/.bin/istanbul cover %s -- -T', options.nodeBin);
exec(cmd, execCb.bind(null, cb));
});
gulp.task('lint', function() {
var pipeline = gulp.src(options.lintPaths)
.pipe(eslint())
.pipe(eslint.formatEach())
.pipe(eslint.failOnError());
});
gulp.task('test-node', function(cb) {
var cmd = util.format('%s "%s" -T', options.nodePath, options.nodeBin);
exec(cmd, execCb.bind(null, cb));
});
gulp.task('test-rhino', function(cb) {
var cmd = util.format('"%s" -T -q "parser=rhino"', options.rhinoBin);
exec(cmd, execCb.bind(null, cb));
});
gulp.task('test-rhino-jsparser', function(cb) {
var cmd = util.format('"%s" -T -q "parser=js"', options.rhinoBin);
exec(cmd, execCb.bind(null, cb));
});
gulp.task('test', ['test-node', 'test-rhino', 'test-rhino-jsparser']);
gulp.task('default', ['lint', 'test']);