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

Commit 8d3d0e4

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 8d3d0e4

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
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: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ var shred = function(shredOptions) {
2222
}
2323
}
2424

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

7390
module.exports = {
7491
shred: shred,
92+
shredSingleExampleDir: shredSingleExampleDir,
7593
shredSingleDir: shredSingleDir,
7694
shredSingleJadeDir: shredSingleJadeDir,
7795
buildShredMap: buildShredMap
@@ -108,12 +126,15 @@ function createShredExamplePackage(shredOptions) {
108126
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
109127
// this just uses globby to 'preglob' the include files ( and exclude the node_modules).
110128
var nmPattern = '**/node_modules/**';
111-
var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } );
129+
var distPattern = '**/dist/**';
130+
var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern, distPattern] } );
131+
132+
console.log(`Shredding ${includeFiles.length} files inside ${shredOptions.examplesDir}`);
112133

113134
readFilesProcessor.sourceFiles = [ {
114135
// Process all candidate files in `src` and its subfolders ...
115136
include: includeFiles ,
116-
exclude: [ '**/node_modules/**', '**/typings/**', '**/packages/**', '**/build/**'],
137+
exclude: [ '**/node_modules/**', '**/dist/**', '**/typings/**', '**/packages/**', '**/build/**'],
117138
// When calculating the relative path to these files use this as the base path.
118139
// So `src/foo/bar.js` will have relative path of `foo/bar.js`
119140
basePath: options.examplesDir

0 commit comments

Comments
 (0)