-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
80 lines (70 loc) · 1.89 KB
/
gulpfile.js
File metadata and controls
80 lines (70 loc) · 1.89 KB
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
/*jslint sloppy: true */
"use strict";
var gulp = require('gulp');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var path = require('path');
var karma = require('karma').server;
var bump = require('gulp-bump');
var git = require('gulp-git');
var tag = require('gulp-tag-version');
function build(paths, suffix) {
var name = 'pocketry';
if (suffix) {
name += '-' + suffix;
}
return gulp.src(paths).
pipe(concat(name + '.js')).
pipe(gulp.dest('dist')).
pipe(rename(name + '.min.js')).
pipe(uglify()).
pipe(gulp.dest('dist'));
}
function test(runOnce, breakOnError) {
var karmaConfig = 'test/config.js';
var cfg = {
configFile: path.join(__dirname, karmaConfig),
singleRun: runOnce
};
// for tdd option run only phantom
if (runOnce === false) {
cfg.browsers = ['PhantomJS', 'Chrome'];
}
karma.start(cfg, function (exitCode) {
if (breakOnError) {
//failed tests make gulp exit
console.error(exitCode);
process.exit(exitCode);
}
});
}
function bumpVersion(importance){
gulp.src('./bower.json')
.pipe(bump({type: importance}))
.pipe(gulp.dest('./'))
.pipe(git.commit('Update version: ' + importance))
.pipe(tag())
.pipe(git.push('origin', 'master', { args: '--tags' }))
.pipe(git.push('github', 'master', { args: '--tags' }))
}
gulp.task('dist', function () {
var paths = [
'bower_components/draggabilly/dist/draggabilly.pkgd.min.js',
'lib/matrix.js',
'lib/ui.js',
'lib/layout.js',
'lib/draggable.js',
'lib/util.js'];
build(paths);
build(['lib/angular_shim.js'].concat(paths), 'angular');
});
gulp.task('test', function () {
test(true, true);
});
gulp.task('tdd', function () {
test(false);
});
gulp.task('major', ['dist'], bumpVersion.bind(null, 'major'));
gulp.task('minor', ['dist'], bumpVersion.bind(null, 'minor'));
gulp.task('patch', ['dist'], bumpVersion.bind(null, 'patch'));