-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (64 loc) · 2.15 KB
/
index.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
'use strict';
module.exports = function(gulp, options) {
var $$ = require('gulp-load-plugins')(),
pipe = require('multipipe'),
runSeq = require('run-sequence'),
util = require('util'),
fs = require('fs'),
exec = require('child_process').exec,
path = require('path'),
Wrapper = require('fin-hypergrid-client-module-wrapper');
options = options || {};
var name = options.name,
version = options.version,
tasks = options.tasks,
buildDir = version + '/build/',
wrapper = new Wrapper(options);
gulp.task('lint', function() {
return gulp.src('index.js')
.pipe($$.eslint())
.pipe($$.eslint.format())
.pipe($$.eslint.failAfterError());
});
gulp.task('test', function(cb) {
var testfile = fs.existsSync('test.js') && 'test.js' ||
fs.existsSync('test/index.js') && 'test/index.js';
if (testfile) {
return gulp.src(testfile)
.pipe($$.mocha({reporter: 'spec'}));
} else {
return cb();
}
});
gulp.task('build', function() {
return gulp.src('index.js')
.pipe($$.header(wrapper.header))
.pipe($$.footer(wrapper.footer))
.pipe(
$$.mirror(
pipe(
$$.rename(name + '.js')
),
pipe(
$$.rename(name + '.min.js'),
$$.uglify().on('error', util.log)
)
)
)
.pipe(gulp.dest(buildDir));
});
gulp.task('doc', function(cb) {
// caveat: this tasks assumes jsdoc.sh is installed: npm --global jsdoc
exec(path.resolve('jsdoc.sh'), function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
if (tasks) {
tasks = Array.isArray(tasks) ? tasks : [tasks];
gulp.task('default', function(callback) {
runSeq.apply(null, tasks.concat(callback));
});
}
};