-
Notifications
You must be signed in to change notification settings - Fork 35
/
gulpfile.js
95 lines (79 loc) · 2.13 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
var gulp = require('gulp');
var path = require('path');
var replace = require('gulp-replace');
var child_process = require('child_process');
var fs = require('fs');
var shell = require('gulp-shell');
var jshint = require('gulp-jshint');
var jshStylish = require('jshint-stylish');
var exec = require('child_process').exec;
var runSequence = require('run-sequence');
var prompt = require('gulp-prompt');
var version;
gulp.task('default', ['publish'], function( next ){
next();
});
gulp.task('publish', [], function( next ){
runSequence('confver', /*'lint',*/ 'pkgver', 'push', 'tag', 'npm', next);
});
gulp.task('confver', ['version'], function(){
return gulp.src('.')
.pipe( prompt.confirm({ message: 'Are you sure version `' + version + '` is OK to publish?' }) )
;
});
gulp.task('version', function( next ){
var now = new Date();
version = process.env['VERSION'];
if( version ){
done();
} else {
exec('git rev-parse HEAD', function( error, stdout, stderr ){
var sha = stdout.substring(0, 10); // shorten so not huge filename
version = [ 'snapshot', sha, +now ].join('-');
done();
});
}
function done(){
console.log('Using version number `%s` for building', version);
next();
}
});
gulp.task('pkgver', ['version'], function(){
return gulp.src([
'package.json',
'bower.json'
])
.pipe( replace(/\"version\"\:\s*\".*?\"/, '"version": "' + version + '"') )
.pipe( gulp.dest('./') )
;
});
gulp.task('push', shell.task([
'git add -A',
'git commit -m "pushing changes for v$VERSION release"',
'git push'
]));
gulp.task('tag', shell.task([
'git tag -a $VERSION -m "tagging v$VERSION"',
'git push origin $VERSION'
]));
gulp.task('npm', shell.task([
'npm publish .'
]));
// http://www.jshint.com/docs/options/
gulp.task('lint', function(){
return gulp.src( 'cytoscape-*.js' )
.pipe( jshint({
funcscope: true,
laxbreak: true,
loopfunc: true,
strict: true,
unused: 'vars',
eqnull: true,
sub: true,
shadow: true,
laxcomma: true
}) )
.pipe( jshint.reporter(jshStylish) )
.pipe( jshint.reporter('fail') )
;
});