-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
75 lines (64 loc) · 2.03 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
// Include gulp
var gulp = require('gulp');
// Include Our Plugins
var jshint = require('gulp-jshint');
var mochaPhantomJS = require('gulp-mocha-phantomjs');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var clean = require('gulp-clean');
var rename = require('gulp-rename');
var git = require('gulp-git');
var bump = require('gulp-bump');
var pkg = require('./package.json');
var paths = {
scripts: ['js/*.js', 'test/**.*js', '!node_modules/**'],
tests: 'test/**.*js'
};
gulp.task('clean', function () {
return gulp.src('./dist', { read: false })
.pipe(clean());
});
gulp.task('build', ['test', 'clean'], function () {
return gulp.src('./js/*.js')
.pipe(concat(pkg.name + '.js'))
.pipe(gulp.dest('./dist'))
.pipe(rename(pkg.name + '.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./dist'));
});
// Lint Task
gulp.task('jshint', function() {
return gulp.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('test', ['jshint'], function () {
timestamp = new Date().toJSON().toString();
return gulp
.src('tests/index.html')
.pipe(mochaPhantomJS({reporter: 'xunit', dump:'TEST-pcapijs-'+timestamp+'.xml'}));
});
gulp.task('bump', ['build'], function () {
return gulp.src(['./package.json', './bower.json'])
.pipe(bump())
.pipe(gulp.dest('./'));
});
gulp.task('tag', ['bump'], function () {
var v = pkg.version;
var message = 'Release ' + v;
return gulp.src('./')
.pipe(git.commit(message))
.pipe(git.tag(v, message))
.pipe(git.push('origin', 'master', '--tags'))
.pipe(gulp.dest('./'));
});
gulp.task('npm', ['tag'], function (done) {
require('child_process').spawn('npm', ['publish'], { stdio: 'inherit' })
.on('close', done);
});
// Our default task.
// Builds our math game and runs our tests
gulp.task('default', ['test', 'build']);
gulp.task('ci', ['build']);
gulp.task('release', ['npm']);