Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit cfa2aaf

Browse files
committed
Gulpfile enhancements: auto-watch all supported template types
1 parent 5c4d065 commit cfa2aaf

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

gulpfile.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,21 @@ gulp.task('cp:styleguide', function(){
102102
.pipe(browserSync.stream());
103103
});
104104

105+
105106
// server and watch tasks
106-
gulp.task('connect', ['lab'], function () {
107+
108+
// watch task utility functions
109+
function getSupportedTemplateExtensions() {
110+
var engines = require('./builder/pattern_engines/pattern_engines');
111+
return engines.getSupportedFileExtensions();
112+
}
113+
function getTemplateWatches() {
114+
return getSupportedTemplateExtensions().map(function (dotExtension) {
115+
return path.resolve(paths().source.patterns, '**/*' + dotExtension);
116+
});
117+
}
118+
119+
gulp.task('connect', ['lab'], function() {
107120
browserSync.init({
108121
server: {
109122
baseDir: path.resolve(paths().public.root)
@@ -135,19 +148,14 @@ gulp.task('connect', ['lab'], function () {
135148

136149
gulp.watch(path.resolve(paths().source.styleguide, '**/*.*'), ['cp:styleguide']);
137150

138-
gulp.watch(
139-
[
140-
path.resolve(paths().source.patterns, '**/*.mustache'),
141-
path.resolve(paths().source.patterns, '**/*.json'),
142-
path.resolve(paths().source.data, '*.json'),
143-
path.resolve(paths().source.fonts + '/*'),
144-
path.resolve(paths().source.images + '/*'),
145-
path.resolve(paths().source.data + '*.json')
146-
],
147-
['lab-pipe'],
148-
function () { browserSync.reload(); }
149-
);
151+
var patternWatches = [
152+
path.resolve(paths().source.patterns, '**/*.json'),
153+
path.resolve(paths().source.data, '*.json'),
154+
path.resolve(paths().source.fonts + '/*'),
155+
path.resolve(paths().source.images + '/*')
156+
].concat(getTemplateWatches());
150157

158+
gulp.watch(patternWatches, ['lab-pipe'], function () { browserSync.reload(); });
151159
});
152160

153161
//unit test

0 commit comments

Comments
 (0)