This repository has been archived by the owner on Oct 8, 2024. It is now read-only.
forked from iVis-at-Bilkent/chise.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
97 lines (82 loc) · 2.48 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
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 browserify = require('browserify');
var buffer = require('vinyl-buffer');
var source = require('vinyl-source-stream');
var gutil = require('gulp-util');
var notifier = require('node-notifier');
var derequire = require('gulp-derequire');
var version;
var browserifyOpts = {
entries: './src/index.js',
debug: true,
standalone: 'sbgnviz'
};
var logError = function( err ){
notifier.notify({ title: 'chise', message: 'Error: ' + err.message });
gutil.log( gutil.colors.red('Error in watch:'), gutil.colors.red(err) );
};
gulp.task('build', function(){
return browserify( browserifyOpts )
.bundle()
.on( 'error', logError )
.pipe( source('chise.js') )
.pipe( buffer() )
.pipe( derequire() )
.pipe( gulp.dest('.') )
});
/*This task is copied from slush-cytoscape-extension*/
gulp.task('publish', [], function( next ){
runSequence('confver', '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" || echo Nothing to commit',
'git push || echo Nothing to push'
]));
gulp.task('tag', shell.task([
'git tag -a v$VERSION -m "tagging v$VERSION"',
'git push origin v$VERSION'
]));
gulp.task('npm', shell.task([
'npm publish .'
]));