UNPKG

react-diagram-schema

Version:

Parses React components from a file entry point and generates/writes a complete schema to a file

22 lines (18 loc) 723 B
const isFunctionDefinedReactComponent = require("./isFunctionDefinedReactComponent"); function extract_exportFunctionDeclarationPaths( exportDeclarationPaths, defaultExport = false, ) { //EXTRACT exported function-defined REACT COMPONENTS const exportFunctionDeclarationPaths = ( defaultExport ? exportDeclarationPaths.filter((path) => path.isExportDefaultDeclaration(), ) : exportDeclarationPaths.filter((path) => path.isExportNamedDeclaration()) ) .map((exportDeclaration) => exportDeclaration.get("declaration")) .filter((p) => isFunctionDefinedReactComponent(p)); return exportFunctionDeclarationPaths; } module.exports = extract_exportFunctionDeclarationPaths;