| 159 | const filepaths = []; |
| 160 | |
| 161 | const gather = filepath => { |
| 162 | if (ignorePattern && ignorePattern.test(filepath)) { |
| 163 | return; |
| 164 | } |
| 165 | const extension = path.extname(filepath); |
| 166 | if (['.jsx', '.js'].includes(extension)) { |
| 167 | components[cleanPath(filepath)] = parseJSX(filepath); |
| 168 | } else if (filepath.endsWith('.tsx')) { |
| 169 | try { |
| 170 | const name = /(.*)\.tsx/.exec(path.basename(filepath))[1]; |
| 171 | filepaths.push(filepath); |
| 172 | names.push(name); |
| 173 | } catch (err) { |
| 174 | process.stderr.write( |
| 175 | `ERROR: Invalid component file ${filepath}: ${err}` |
| 176 | ); |
| 177 | } |
| 178 | } |
| 179 | }; |
| 180 | |
| 181 | sources.forEach(sourcePath => { |
| 182 | if (fs.lstatSync(sourcePath).isDirectory()) { |