forked from willsoto/angular-chartist.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
145 lines (124 loc) · 3.42 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
'use strict';
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var tagVersion = require('gulp-tag-version');
var wrap = require('gulp-wrap-umd');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var fs = require('fs');
var changelog = require('conventional-changelog');
// testing
var karma = require('karma').server;
var config = {
source: 'src',
dist: 'dist',
example: 'example'
};
var release = function(importance) {
gulp.src(['./bower.json', './package.json'])
.pipe($.bump({
type: importance
}))
.pipe(gulp.dest('./'))
.pipe($.git.commit('chore: bumps package version'))
.pipe($.filter('bower.json'))
.pipe(tagVersion());
};
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: './example'
}
});
});
gulp.task('changelog', function(done) {
function changeParsed(err, log) {
if (err) {
return done(err);
}
fs.writeFile('CHANGELOG.md', log, done);
}
fs.readFile('./package.json', 'utf8', function(err, data) {
var ref$ = JSON.parse(data);
var repository = ref$.repository;
var version = ref$.version;
changelog({
repository: repository.url,
version: version
}, changeParsed);
});
});
gulp.task('clean', function(cb) {
require('del')([config.dist, config.example + '/lib'], {
force: true
}, cb);
});
gulp.task('enforce', function() {
var fs = require('fs');
var validateCommit = '.git/hooks/commit-msg';
if (!fs.existsSync(validateCommit)) {
// copy the file over
fs.createReadStream('./validate-commit-msg.js')
.pipe(fs.createWriteStream(validateCommit));
// make it executable
fs.chmodSync(validateCommit, '0755');
}
});
gulp.task('jshint', function() {
return gulp.src(config.source + '/*.js')
.pipe($.plumber())
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'));
});
gulp.task('serve', ['browser-sync'], function() {
gulp.watch(config.source + '/*.js', [
'js',
browserSync.reload
]);
});
gulp.task('js', ['jshint', 'clean'], function() {
return gulp.src(config.source + '/*.js')
.pipe(wrap({
exports: 'angularChartist',
namespace: 'angularChartist',
deps: [{
name: 'angular',
paramName: 'angular',
globalName: 'angular'
}, {
name: 'chartist',
paramName: 'Chartist',
globalName: 'Chartist'
}]
}))
.pipe($.beautify())
.pipe(gulp.dest(config.dist))
.pipe(gulp.dest(config.example + '/lib'))
.pipe($.uglify())
.pipe($.rename({
extname: '.min.js'
}))
.pipe(gulp.dest(config.dist))
.pipe(gulp.dest(config.example + '/lib'));
});
gulp.task('test', function(done) {
karma.start({
configFile: __dirname + '/karma.conf.js'
}, done);
});
gulp.task('default', [
'js',
'serve'
]);
gulp.task('dist', [
'js'
]);
gulp.task('patch', ['dist', 'changelog'], function() {
return release('patch');
});
gulp.task('feature', ['dist', 'changelog'], function() {
return release('minor');
});
gulp.task('release', ['dist', 'changelog'], function() {
return release('major');
});