-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
124 lines (105 loc) · 2.77 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
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var bs = require('browser-sync');
var reload = bs.reload;
var del = require('del');
var vf = require('vinyl-paths');
var sync = require('run-sequence');
var karma = require('karma').server;
var changelog = require('conventional-changelog');
var fs = require('fs');
var bump = require('gulp-bump');
var yargs = require('yargs');
var argv = yargs.argv,
validBumpTypes = "major|minor|patch|prerelease".split("|"),
Bump = (argv.bump || 'patch').toLowerCase();
if(validBumpTypes.indexOf(Bump) === -1) {
throw new Error('Unrecognized bump "' + Bump + '".');
}
var args = { bump: Bump };
// Paths to all src files
var paths = {
src: ['src/**/*.js'],
dev: ['dev/index.html', 'dev/app.js', 'dev/template.html'],
dist: './dist',
specs: 'specs/**/*.js',
doc: ['./docs']
};
// lint the coffee
gulp.task('lint', function() {
return gulp.src(paths.src)
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.ngAnnotate())
// .pipe($.uglify())
.pipe(gulp.dest(paths.dist));
});
gulp.task('clean', function() {
return gulp.src([paths.dist + '/**/*.**'])
.pipe(vf(del));
});
// run dev env for visually inspecting the plugin
gulp.task('dev', ['build'], function(done) {
bs({
port: 9500,
server: {
baseDir: ['./dev', './dist', './bower_components']
}
}, done);
gulp.watch(paths.dev, reload);
gulp.watch(paths.src, ['build', reload]);
});
// run karma test
gulp.task('test', function(done) {
karma.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done);
});
// for ci, use phantom
gulp.task('test:ci', function(done){
karma.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true,
browsers: ['PhantomJS']
}, done);
});
gulp.task('travis', function(done) {
sync('build', 'test:ci', done);
});
gulp.task('bump-version', function(){
return gulp.src(['./package.json', './bower.json'])
.pipe(bump({type:args.bump })) //major|minor|patch|prerelease
.pipe(gulp.dest('./'));
});
gulp.task('changelog', function(callback) {
var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
return changelog({
repository: pkg.repository.url,
version: pkg.version,
file: './CHANGELOG.md',
subtitle: argv.codename || ''
}, function(err, log) {
fs.writeFileSync('./CHANGELOG.md', log);
});
});
gulp.task('build', ['clean'], function(done) {
sync('lint', done);
});
gulp.task('del:change', function() {
return gulp.src('./CHANGELOG.md')
.pipe(vf(del));
});
gulp.task('release', function(done){
return sync(
'build',
'lint',
'bump-version',
'del:change',
'changelog',
done
);
});
gulp.task('default', ['build'], function() {
gulp.watch(paths.src, ['lint']);
});