new-component
Advanced tools
Comparing version 2.0.0 to 3.0.0
{ | ||
"name": "new-component", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "CLI for creating new React components", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/joshwcomeau/new-component", |
@@ -21,3 +21,3 @@ <p align="center"> | ||
- Simple CLI interface for adding Component, PureComponent, or Stateless Functional components. | ||
- Simple CLI interface for adding React components. | ||
- Uses [Prettier](https://github.com/prettier/prettier) to stylistically match the existing project. | ||
@@ -24,0 +24,0 @@ - Offers global config, which can be overridden on a project-by-project basis. |
@@ -47,5 +47,18 @@ /* | ||
module.exports.buildPrettifier = (prettierConfig) => (text) => | ||
prettier.format(text, prettierConfig); | ||
module.exports.buildPrettifier = (prettierConfig) => { | ||
// If they haven't supplied a prettier config, check for a | ||
// `.prettierrc`! | ||
let config = prettierConfig; | ||
if (!config) { | ||
const currentPath = process.cwd(); | ||
const config = requireOptional( | ||
`/${currentPath}/.prettierrc` | ||
); | ||
} | ||
return (text) => prettier.format(text, config); | ||
} | ||
// Emit a message confirming the creation of the component | ||
@@ -52,0 +65,0 @@ const colors = { |
@@ -62,6 +62,7 @@ #!/usr/bin/env node | ||
const filePath = `${componentDir}/${componentName}.${program.extension}`; | ||
const indexPath = `${componentDir}/index.js`; | ||
const indexPath = `${componentDir}/index.${program.extension}`; | ||
// Our index template is super straightforward, so we'll just inline it for now. | ||
const indexTemplate = prettify(`\ | ||
export * from './${componentName}'; | ||
export { default } from './${componentName}'; | ||
@@ -68,0 +69,0 @@ `); |
85274
282