Skip to content

Commit

Permalink
docs(ComponentExample): fix code editor body regex (Semantic-Org#2481)
Browse files Browse the repository at this point in the history
docs(ComponentExample): fix code editor body regex
  • Loading branch information
Nathan Kamm authored and Brandon Lawrence committed Mar 14, 2018
1 parent 2482ddb commit a1e285c
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ class ComponentExample extends Component {
// capture the default export so we can return it from the IIFE
const defaultExport = _.get(/export\s+default\s+(?:class|function)?(?:\s+)?(\w+)/.exec(sourceCode), '[1]')

// consider everything after the imports to be the body
// remove `export` statements except `export default class|function`
const body = _.get(/import[\s\S]*from.*\n([\s\S]*)/.exec(sourceCode), '[1]', '')
const body = _.get(/(export\sdefault\sclass|const|class\s\S*\sextends)[\s\S]*/.exec(sourceCode), '[0]', '')
.replace(/export\s+default\s+(?!class|function)\w+([\s\n]+)?/, '') // remove `export default Foo` statements
.replace(/export\s+default\s+/, '') // remove `export default ...`

Expand Down

0 comments on commit a1e285c

Please sign in to comment.