-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
130 lines (113 loc) · 3.39 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
////
//// Usage: ./node_modules/.bin/gulp build, clean, test, etc.
////
var gulp = require('gulp');
//var jsdoc = require('gulp-jsdoc');
var mocha = require('gulp-mocha');
var uglify = require('gulp-uglify');
var rename = require("gulp-rename");
var git = require('gulp-git');
var bump = require('gulp-bump');
var del = require('del');
var shell = require('gulp-shell');
var paths = {
readme: ['./README.md'],
tests: ['tests/*.test.js', 'tests/*.tests.js'],
docable: ['lib/*.js', './README.md'],
transients:['./doc/*', '!./doc/README.md']
};
// Browser runtime environment construction.
gulp.task('build', ['patch-bump', 'doc']);
gulp.task('patch-bump', function(cb){
gulp.src('./package.json')
.pipe(bump({type: 'patch'}))
.pipe(gulp.dest('./'));
cb(null);
});
gulp.task('minor-bump', function(cb){
gulp.src('./package.json')
.pipe(bump({type: 'minor'}))
.pipe(gulp.dest('./'));
cb(null);
});
gulp.task('major-bump', function(cb){
gulp.src('./package.json')
.pipe(bump({type: 'major'}))
.pipe(gulp.dest('./'));
cb(null);
});
// Build docs directory with JSDoc.
//gulp.task('doc', ['md-to-org', 'jsdoc']);
gulp.task('doc', ['jsdoc']);
// Build docs directory with JSDoc.
// Completely dependent on clean before running doc.
// gulp.task('jsdoc', ['clean'], function(cb) {
// gulp.src(paths.docable, paths.readme)
// .pipe(jsdoc('./doc'));
// cb(null);
// });
// TODO: Ugh--do this manually until gulp-jsdoc gets its act together.
gulp.task('jsdoc', ['clean'], function(cb) {
gulp.src('')
.pipe(shell([
'./node_modules/.bin/jsdoc --verbose --template ./node_modules/jsdoc-baseline --readme ./README.md --destination ./doc/ ./lib/*.js'
]));
cb(null);
});
// Get rid of anything that is transient.
gulp.task('clean', function(cb) {
del(paths.transients);
cb(null);
});
// Testing with mocha/chai.
gulp.task('test', function() {
return gulp.src(paths.tests, { read: false }).pipe(mocha({
reporter: 'spec',
globals: {
// Use a different should.
should: require('chai').should()
}
}));
});
//gulp.task('release', ['build', 'publish-npm', 'git-commit', 'git-tag']);
gulp.task('release', ['build', 'publish-npm']);
// Needs to have ""
gulp.task('publish-npm', function() {
var npm = require("npm");
npm.load(function (er, npm) {
// NPM
npm.commands.publish();
});
});
gulp.task('git-commit', function(){
console.log('TODO: WORK IN PROGRESS');
// Make a note in the git repo.
var pkg = require('./package.json');
var pver = pkg.version;
gulp.src('./*')
.pipe(git.commit('Package/version tracking for go-exp/widget: ' + pver));
});
gulp.task('git-tag', function(){
console.log('TODO: WORK IN PROGRESS');
// Make a note in the git repo.
var pkg = require('./package.json');
var pver = pkg.version;
git.tag('go-exp-widget-' + pver, 'version message', function (err){
if(err){ throw err; }
});
});
// Rerun doc build when a file changes.
gulp.task('watch-doc', function() {
gulp.watch(paths.docable, ['doc']);
gulp.watch(paths.readme, ['doc']);
});
// Rerun doc build when a file changes.
gulp.task('watch-test', function() {
gulp.watch(paths.docable, ['test']);
gulp.watch(paths.tests, ['test']);
});
// The default task (called when you run `gulp` from cli)
//gulp.task('default', ['watch', 'scripts', 'images']);
gulp.task('default', function() {
console.log("'allo 'allo!");
});