From eb7533a6effccb89bbdf74b67517fd2b3bc8156f Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Fri, 13 Nov 2015 09:37:43 +0000 Subject: [PATCH] chore(gulpfile): ignore `node_modules` folders in examples This should speed up watching as it is unusual to update files in these folders during normal development. If you do change files in an example `node_modules` folder then you must restart the gulp task to trigger the shredder and reload. --- gulpfile.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index aa18023eb7..cdc7d5c0de 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -214,7 +214,7 @@ function watchAndSync(options, cb) { apiSourceWatch(browserSync.reload); } if (options.apiExamples) { - apiExampleWatch(browserSync.reload); + apiExamplesWatch(browserSync.reload); } if (options.localFiles) { gulp.watch(NOT_API_DOCS_GLOB, browserSync.reload); @@ -255,12 +255,13 @@ function apiSourceWatch(postBuildAction) { gutil.log('Event type: ' + event.event); // added, changed, or deleted gutil.log('Event path: ' + event.path); // The path of the modified file - Q.all([buildApiDocs('ts'), buildApiDocs('js')]).then(postBuildAction); + return Q.all([buildApiDocs('ts'), buildApiDocs('js')]).then(postBuildAction); }); } -function apiExampleWatch(postShredAction) { - var examplesPattern = [path.join(ANGULAR_PROJECT_PATH, 'modules/angular2/examples/**/*.*')]; +function apiExamplesWatch(postShredAction) { + var examplesPattern = + path.join(ANGULAR_PROJECT_PATH, 'modules/angular2/examples/**/!(node_modules)/*.*'); var cleanPath = [path.join(_apiShredOptions.fragmentsDir, '**/*.*'), '!**/*.ovr.*']; watch(examplesPattern, {readDelay: 500}, function (event, done) { @@ -274,6 +275,18 @@ function apiExampleWatch(postShredAction) { }); } +function devGuideExamplesWatch(shredOptions, postShredAction) { + var pattern = path.join(shredOptions.examplesDir, "**/!(node_modules)/**/*"); + watch(pattern, { readDelay: 500 }, function (event, done) { + gutil.log('Dev Guide example changed') + gutil.log('Event type: ' + event.event); // added, changed, or deleted + gutil.log('Event path: ' + event.path); // The path of the modified file + return docShredder.shredSingleDir(shredOptions, event.path).then(postShredAction); + }); +} + + + // Generate the API docs for the specified language, if not specified then it defaults to ts function buildApiDocs(targetLanguage) { var ALLOWED_LANGUAGES = ['ts', 'js']; @@ -304,18 +317,6 @@ function buildApiDocs(targetLanguage) { } } -function devGuideExamplesWatch(shredOptions, postShredAction) { - var pattern = path.join(shredOptions.examplesDir, "**/*.*"); - watch([pattern], { readDelay: 500 }, function (event, done) { - gutil.log('Event type: ' + event.event); // added, changed, or deleted - gutil.log('Event path: ' + event.path); // The path of the modified file - docShredder.shredSingleDir(shredOptions, event.path).then(function () { - postShredAction && postShredAction(); - }); - }); -} - - function buildShredMaps(shouldWrite) { var options = { devguideExamplesDir: _devguideShredOptions.examplesDir,