@@ -4,7 +4,13 @@ const fs = require('fs');
4
4
const path = require ( 'path' ) ;
5
5
const reactDocs = require ( 'react-docgen' ) ;
6
6
7
- const componentPaths = process . argv . slice ( 2 ) ;
7
+ const componentPaths = process . argv . slice ( 3 ) ;
8
+ const ignorePattern = new RegExp ( process . argv [ 2 ] ) ;
9
+
10
+ const excludedDocProps = [
11
+ 'setProps' , 'id' , 'className' , 'style' , 'dashEvents' , 'fireEvent'
12
+ ] ;
13
+
8
14
if ( ! componentPaths . length ) {
9
15
help ( ) ;
10
16
process . exit ( 1 ) ;
@@ -36,8 +42,7 @@ function writeError(msg, filePath) {
36
42
}
37
43
38
44
function checkWarn ( name , value ) {
39
- const excluded = [ 'setProps' , 'id' , 'className' , 'style' , 'dashEvents' , 'fireEvent' ] ;
40
- if ( value . length < 1 && ! excluded . includes ( name ) ) {
45
+ if ( value . length < 1 && ! excludedDocProps . includes ( name . split ( '.' ) . pop ( ) ) ) {
41
46
process . stderr . write ( `\nDescription for ${ name } is missing!\n` )
42
47
}
43
48
}
@@ -69,6 +74,9 @@ function parseFile(filepath) {
69
74
}
70
75
71
76
function collectMetadataRecursively ( componentPath ) {
77
+ if ( ignorePattern . test ( componentPath ) ) {
78
+ return ;
79
+ }
72
80
if ( fs . lstatSync ( componentPath ) . isDirectory ( ) ) {
73
81
let dirs ;
74
82
try {
@@ -80,11 +88,11 @@ function collectMetadataRecursively(componentPath) {
80
88
const filepath = path . join ( componentPath , filename ) ;
81
89
if ( fs . lstatSync ( filepath ) . isDirectory ( ) ) {
82
90
collectMetadataRecursively ( filepath ) ;
83
- } else {
91
+ } else if ( ! ignorePattern . test ( filename ) ) {
84
92
parseFile ( filepath ) ;
85
93
}
86
94
} ) ;
87
- } else {
95
+ } else if ( ! ignorePattern . test ( componentPath ) ) {
88
96
parseFile ( componentPath ) ;
89
97
}
90
98
}
0 commit comments