-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
80 lines (67 loc) · 2.09 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
var gulp = require('gulp'),
bs = require('browser-sync').create(),
bg = require("gulp-bg"),
ps = require('ps-node');
var git = require('gulp-git');
var bump = require('gulp-bump');
var tag_version = require('gulp-tag-version');
var filter = require('gulp-filter');
var POLYSERVE_PORT = 8080,
elementName = 'wid-cards-grid';
var browserSyncConfig = function(path, cb) {
bs.init({
proxy: 'localhost:' + POLYSERVE_PORT,
startPath: path
});
bs.reload;
process.on('exit', function() {
bs.exit();
});
};
var watchComponent = function() {
gulp.watch(['./*.html', 'demo/**/*.html', 'test/**/*.html'], bs.reload);
};
gulp.task('polyserve', function(cb) {
ps.lookup({
command: 'polyserve',
psargs: '-f'
}, function(err, resultList) {
if (err) {
throw new Error(err);
}
if (!resultList.length) {
bg('./node_modules/polyserve/bin/polyserve', '-p ' + POLYSERVE_PORT)();
}
cb();
});
});
gulp.task('serve', ['polyserve'], function(cb) {
browserSyncConfig('/components/' + elementName + '/demo/', cb);
watchComponent();
});
gulp.task('serve:doc', ['polyserve'], function(cb) {
browserSyncConfig('/components/' + elementName + '/', cb);
watchComponent();
});
gulp.task('test:watch', ['polyserve'], function(cb) {
browserSyncConfig('/components/' + elementName + '/test/', cb);
watchComponent();
});
try { require('web-component-tester').gulp.init(gulp); } catch (err) {}
function inc(importance) {
// get all the files to bump version in
return gulp.src(['./package.json', './bower.json'])
// bump the version number in those files
.pipe(bump({type: importance}))
// save it back to filesystem
.pipe(gulp.dest('./'))
// commit the changed version number
.pipe(git.commit('bumps package version'))
// read only one file to get the version number
.pipe(filter('bower.json'))
// **tag it in the repository**
.pipe(tag_version());
}
gulp.task('patch', function() { return inc('patch'); });
gulp.task('feature', function() { return inc('minor'); });
gulp.task('release', function() { return inc('major'); });