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

Commit 49a7bc3

Browse files
filipesilvawardbell
authored andcommitted
chore: Partition example shredder to do one directory at a time
also exclude /dist/ folder and exclude _examples from jade shredder closes #1661
1 parent c50954d commit 49a7bc3

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

gulpfile.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,13 @@ gulp.task('_harp-compile', function() {
615615
});
616616

617617
gulp.task('_shred-devguide-examples', ['_shred-clean-devguide', '_copy-example-boilerplate'], function() {
618-
return docShredder.shred( _devguideShredOptions);
618+
// Split big shredding task into partials 2016-06-14
619+
var examplePaths = globby.sync(EXAMPLES_PATH+'/*/', {ignore: ['/node_modules', 'typings/', '_protractor/']});
620+
var promise = Promise.resolve(true);
621+
examplePaths.forEach(function (examplePath) {
622+
promise = promise.then(() => docShredder.shredSingleExampleDir(_devguideShredOptions, examplePath));
623+
});
624+
return promise;
619625
});
620626

621627
gulp.task('_shred-devguide-shared-jade', ['_shred-clean-devguide-shared-jade', '_copy-example-boilerplate'], function() {
@@ -978,7 +984,7 @@ function devGuideExamplesWatch(shredOptions, postShredAction) {
978984
// removed this version because gulp.watch has the same glob issue that dgeni has.
979985
// var excludePattern = '!' + path.join(shredOptions.examplesDir, '**/node_modules/**/*.*');
980986
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
981-
var ignoreThese = [ '**/node_modules/**', '**/_fragments/**',
987+
var ignoreThese = [ '**/node_modules/**', '**/_fragments/**', '**/dist/**', '**/typings/**',
982988
'**/dart/.pub/**', '**/dart/build/**', '**/dart/packages/**'];
983989
var files = globby.sync( [includePattern], { ignore: ignoreThese });
984990
gulp.watch([files], {readDelay: 500}, function (event, done) {
@@ -994,7 +1000,7 @@ function devGuideSharedJadeWatch(shredOptions, postShredAction) {
9941000
// removed this version because gulp.watch has the same glob issue that dgeni has.
9951001
// var excludePattern = '!' + path.join(shredOptions.jadeDir, '**/node_modules/**/*.*');
9961002
// gulp.watch([includePattern, excludePattern], {readDelay: 500}, function (event, done) {
997-
var files = globby.sync( [includePattern], { ignore: [ '**/node_modules/**', '**/_fragments/**']});
1003+
var files = globby.sync( [includePattern], { ignore: [ '**/node_modules/**', '**/_examples/**', '**/_fragments/**']});
9981004
gulp.watch([files], {readDelay: 500}, function (event, done) {
9991005
gutil.log('Dev Guide jade file changed')
10001006
gutil.log('Event type: ' + event.type); // added, changed, or deleted

tools/doc-shredder/doc-shredder.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var del = require('del');
44
var Dgeni = require('dgeni');
55
var _ = require('lodash');
66
var globby = require('globby');
7+
var ignoreDirs = ['**/node_modules/**', '**/dist/**', '**/typings/**'];
78

89
var shred = function(shredOptions) {
910
try {
@@ -22,6 +23,23 @@ var shred = function(shredOptions) {
2223
}
2324
}
2425

26+
var shredSingleExampleDir = function(shredOptions, fileDir) {
27+
shredOptions = resolveShredOptions(shredOptions);
28+
var relativePath = path.relative(shredOptions.examplesDir, fileDir);
29+
var examplesDir = path.join(shredOptions.examplesDir, relativePath);
30+
var fragmentsDir = path.join(shredOptions.fragmentsDir, relativePath);
31+
var options = {
32+
includeSubdirs: true,
33+
examplesDir: examplesDir,
34+
fragmentsDir: fragmentsDir
35+
}
36+
var cleanPath = path.join(fragmentsDir, '*.*')
37+
return del([ cleanPath, '!**/*.ovr.*']).then(function(paths) {
38+
// console.log('Deleted files/folders:\n', paths.join('\n'));
39+
return shred(options);
40+
});
41+
}
42+
2543
var shredSingleDir = function(shredOptions, filePath) {
2644
shredOptions = resolveShredOptions(shredOptions);
2745
var fileDir = path.dirname(filePath);
@@ -72,6 +90,7 @@ var buildShredMap = function(shredMapOptions) {
7290

7391
module.exports = {
7492
shred: shred,
93+
shredSingleExampleDir: shredSingleExampleDir,
7594
shredSingleDir: shredSingleDir,
7695
shredSingleJadeDir: shredSingleJadeDir,
7796
buildShredMap: buildShredMap
@@ -107,13 +126,14 @@ function createShredExamplePackage(shredOptions) {
107126

108127
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
109128
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
110-
var nmPattern = '**/node_modules/**';
111-
var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } );
129+
var includeFiles = globby.sync( includeFiles, { ignore: ignoreDirs } );
130+
131+
console.log(`Shredding ${includeFiles.length} files inside ${shredOptions.examplesDir}`);
112132

113133
readFilesProcessor.sourceFiles = [ {
114134
// Process all candidate files in `src` and its subfolders ...
115135
include: includeFiles ,
116-
exclude: [ '**/node_modules/**', '**/typings/**', '**/packages/**', '**/build/**'],
136+
exclude: [ '**/node_modules/**', '**/dist/**', '**/typings/**', '**/packages/**', '**/build/**'],
117137
// When calculating the relative path to these files use this as the base path.
118138
// So `src/foo/bar.js` will have relative path of `foo/bar.js`
119139
basePath: options.examplesDir
@@ -159,8 +179,7 @@ function createShredJadePackage(shredOptions) {
159179

160180
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
161181
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
162-
var nmPattern = '**/node_modules/**';
163-
var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } );
182+
var includeFiles = globby.sync( includeFiles, { ignore: ignoreDirs } );
164183

165184
readFilesProcessor.sourceFiles = [ {
166185
// Process all candidate files in `src` and its subfolders ...
@@ -212,8 +231,7 @@ var createShredMapPackage = function(mapOptions) {
212231

213232
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
214233
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
215-
var nmPattern = '**/node_modules/**';
216-
var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } );
234+
var includeFiles = globby.sync( includeFiles, { ignore: ignoreDirs } );
217235

218236

219237
readFilesProcessor.sourceFiles = [ {

0 commit comments

Comments
 (0)