-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
108 lines (93 loc) · 3.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
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
var gulp = require('gulp'),
bs = require('browser-sync').create(),
bg = require('gulp-bg'),
ps = require('ps-node'),
babel = require('gulp-babel'),
sourcemaps = require('gulp-sourcemaps'),
crisper = require('gulp-crisper'),
gulpif = require('gulp-if'),
jshint = require('gulp-jshint'),
git = require('gulp-git'),
bump = require('gulp-bump'),
tagVersion = require('gulp-tag-version'),
filter = require('gulp-filter');
var POLYSERVE_PORT = 8080,
elementName = 'wid-card-progress-value';
var browserSyncConfig = function(path, cb) {
bs.init({
proxy: 'localhost:' + POLYSERVE_PORT,
startPath: path
});
bs.reload();
process.on('exit', function() {
bs.exit();
});
cb();
};
var watchComponent = function() {
gulp.watch(['./src/*.{js,html}', 'demo/**/*.html', 'test/**/*.html'], ['js', bs.reload]);
};
// Transpile all JS to ES5.
gulp.task('js', ['jshint'], function () {
return gulp.src(['src/**/*.{js,html}'])
.pipe(sourcemaps.init())
.pipe(gulpif('*.html', crisper())) // Extract JS from .html files
.pipe(gulpif('*.js', babel()))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('.'));
});
// Lint JavaScript
gulp.task('jshint', function () {
return gulp.src([
'src/**/*.{js,html}',
'gulpfile.js'
])
.pipe(jshint.extract()) // Extract JS from .html files
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(gulpif(!bs.active, jshint.reporter('fail')));
});
gulp.task('polyserve', ['js'], 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 for ' + importance + 'release.'))
// read only one file to get the version number
.pipe(filter('bower.json'))
// **tag it in the repository**
.pipe(tagVersion());
}
gulp.task('patch', function() { return inc('patch'); });
gulp.task('feature', function() { return inc('minor'); });
gulp.task('release', function() { return inc('major'); });