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

Commit 745f055

Browse files
filipesilvawardbell
authored andcommitted
chore(gulp): add focus flag (#2258)
1 parent 58a787a commit 745f055

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

gulpfile.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,11 +1147,16 @@ function watchAndSync(options, cb) {
11471147
var browserSync = require('browser-sync').create();
11481148
browserSync.init({proxy: 'localhost:9000'});
11491149

1150+
// When using the --focus=name flag, only **/name/**/*.* example files and
1151+
// **/name.jade files are watched. This is useful for performance reasons.
1152+
// Example: gulp serve-and-sync --focus=architecture
1153+
var focus = argv.focus;
1154+
11501155
if (options.devGuide) {
1151-
devGuideExamplesWatch(_devguideShredOptions, browserSync.reload);
1156+
devGuideExamplesWatch(_devguideShredOptions, browserSync.reload, focus);
11521157
}
11531158
if (options.devGuideJade) {
1154-
devGuideSharedJadeWatch( { jadeDir: DOCS_PATH}, browserSync.reload);
1159+
devGuideSharedJadeWatch( { jadeDir: DOCS_PATH}, browserSync.reload, focus);
11551160
}
11561161
if (options.apiDocs) {
11571162
apiSourceWatch(browserSync.reload);
@@ -1218,8 +1223,9 @@ function apiExamplesWatch(postShredAction) {
12181223
});
12191224
}
12201225

1221-
function devGuideExamplesWatch(shredOptions, postShredAction) {
1222-
var includePattern = path.join(shredOptions.examplesDir, '**/*.*');
1226+
function devGuideExamplesWatch(shredOptions, postShredAction, focus) {
1227+
var watchPattern = focus ? '**/' + focus + '/**/*.*' : '**/*.*';
1228+
var includePattern = path.join(shredOptions.examplesDir, watchPattern);
12231229
// removed this version because gulp.watch has the same glob issue that dgeni has.
12241230
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
12251231
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
@@ -1235,8 +1241,9 @@ function devGuideExamplesWatch(shredOptions, postShredAction) {
12351241
});
12361242
}
12371243

1238-
function devGuideSharedJadeWatch(shredOptions, postShredAction) {
1239-
var includePattern = path.join(DOCS_PATH, '**/*.jade');
1244+
function devGuideSharedJadeWatch(shredOptions, postShredAction, focus) {
1245+
var watchPattern = focus ? '**/' + focus + '.jade' : '**/*.jade';
1246+
var includePattern = path.join(DOCS_PATH, watchPattern);
12401247
// removed this version because gulp.watch has the same glob issue that dgeni has.
12411248
// var excludePattern = '!' + path.join(shredOptions.jadeDir, '**/node_modules/**/*.*');
12421249
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {

0 commit comments

Comments
 (0)