chore(gulp): add focus flag (#2258)

This commit is contained in:
Filipe Silva 2016-09-03 02:54:45 +01:00 committed by Ward Bell
parent 58a787a34d
commit 745f0554e0

View File

@ -1147,11 +1147,16 @@ function watchAndSync(options, cb) {
var browserSync = require('browser-sync').create(); var browserSync = require('browser-sync').create();
browserSync.init({proxy: 'localhost:9000'}); browserSync.init({proxy: 'localhost:9000'});
// When using the --focus=name flag, only **/name/**/*.* example files and
// **/name.jade files are watched. This is useful for performance reasons.
// Example: gulp serve-and-sync --focus=architecture
var focus = argv.focus;
if (options.devGuide) { if (options.devGuide) {
devGuideExamplesWatch(_devguideShredOptions, browserSync.reload); devGuideExamplesWatch(_devguideShredOptions, browserSync.reload, focus);
} }
if (options.devGuideJade) { if (options.devGuideJade) {
devGuideSharedJadeWatch( { jadeDir: DOCS_PATH}, browserSync.reload); devGuideSharedJadeWatch( { jadeDir: DOCS_PATH}, browserSync.reload, focus);
} }
if (options.apiDocs) { if (options.apiDocs) {
apiSourceWatch(browserSync.reload); apiSourceWatch(browserSync.reload);
@ -1218,8 +1223,9 @@ function apiExamplesWatch(postShredAction) {
}); });
} }
function devGuideExamplesWatch(shredOptions, postShredAction) { function devGuideExamplesWatch(shredOptions, postShredAction, focus) {
var includePattern = path.join(shredOptions.examplesDir, '**/*.*'); var watchPattern = focus ? '**/' + focus + '/**/*.*' : '**/*.*';
var includePattern = path.join(shredOptions.examplesDir, watchPattern);
// removed this version because gulp.watch has the same glob issue that dgeni has. // removed this version because gulp.watch has the same glob issue that dgeni has.
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*'); // var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) { // gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
@ -1235,8 +1241,9 @@ function devGuideExamplesWatch(shredOptions, postShredAction) {
}); });
} }
function devGuideSharedJadeWatch(shredOptions, postShredAction) { function devGuideSharedJadeWatch(shredOptions, postShredAction, focus) {
var includePattern = path.join(DOCS_PATH, '**/*.jade'); var watchPattern = focus ? '**/' + focus + '.jade' : '**/*.jade';
var includePattern = path.join(DOCS_PATH, watchPattern);
// removed this version because gulp.watch has the same glob issue that dgeni has. // removed this version because gulp.watch has the same glob issue that dgeni has.
// var excludePattern = '!' + path.join(shredOptions.jadeDir, '**/node_modules/**/*.*'); // var excludePattern = '!' + path.join(shredOptions.jadeDir, '**/node_modules/**/*.*');
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) { // gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {