@@ -4,6 +4,7 @@ var del = require('del');
4
4
var Dgeni = require ( 'dgeni' ) ;
5
5
var _ = require ( 'lodash' ) ;
6
6
var globby = require ( 'globby' ) ;
7
+ var ignoreDirs = [ '**/node_modules/**' , '**/dist/**' , '**/typings/**' ] ;
7
8
8
9
var shred = function ( shredOptions ) {
9
10
try {
@@ -22,6 +23,23 @@ var shred = function(shredOptions) {
22
23
}
23
24
}
24
25
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
+
25
43
var shredSingleDir = function ( shredOptions , filePath ) {
26
44
shredOptions = resolveShredOptions ( shredOptions ) ;
27
45
var fileDir = path . dirname ( filePath ) ;
@@ -72,6 +90,7 @@ var buildShredMap = function(shredMapOptions) {
72
90
73
91
module . exports = {
74
92
shred : shred ,
93
+ shredSingleExampleDir : shredSingleExampleDir ,
75
94
shredSingleDir : shredSingleDir ,
76
95
shredSingleJadeDir : shredSingleJadeDir ,
77
96
buildShredMap : buildShredMap
@@ -107,13 +126,14 @@ function createShredExamplePackage(shredOptions) {
107
126
108
127
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
109
128
// 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 } ` ) ;
112
132
113
133
readFilesProcessor . sourceFiles = [ {
114
134
// Process all candidate files in `src` and its subfolders ...
115
135
include : includeFiles ,
116
- exclude : [ '**/node_modules/**' , '**/typings/**' , '**/packages/**' , '**/build/**' ] ,
136
+ exclude : [ '**/node_modules/**' , '**/dist/**' , '**/ typings/**', '**/packages/**' , '**/build/**' ] ,
117
137
// When calculating the relative path to these files use this as the base path.
118
138
// So `src/foo/bar.js` will have relative path of `foo/bar.js`
119
139
basePath : options . examplesDir
@@ -159,8 +179,7 @@ function createShredJadePackage(shredOptions) {
159
179
160
180
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
161
181
// 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 } ) ;
164
183
165
184
readFilesProcessor . sourceFiles = [ {
166
185
// Process all candidate files in `src` and its subfolders ...
@@ -212,8 +231,7 @@ var createShredMapPackage = function(mapOptions) {
212
231
213
232
// HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
214
233
// 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 } ) ;
217
235
218
236
219
237
readFilesProcessor . sourceFiles = [ {
0 commit comments