snaerth / create-react-component-folder

Creates react component folder structure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: Set Defaults on package.json

shelldandy opened this issue · comments

Maybe something to read from package.json some defaults for example to leave the --reactnative option on or scss or something along those lines 🤔

So the proposal would be maybe adding a crcf key in the package.json as an array of default options

crcf: [
  "typescript",
  "scss"
]

So that on the CLI you can just run crcf and that would by default run it with those options and if you added custom options then those would be used and not the defaults

Thoughts...

🤔

@shelldandy That's an good idea. It has been on my todo list to set default or save default. I hadn't thought to set a specific prop in package.json. This will be my next assignment. And I am always open to pull requests :)

Maybe even better could be with cosmiconfig (which is what eslint, stylelint etc use)

https://github.com/davidtheclark/cosmiconfig

const cosmiconfig = require('cosmiconfig');
// ...
const explorer = cosmiconfig(moduleName);

// Search for a configuration by walking up directories.
// See documentation for search, below.
explorer.search()
  .then((result) => {
    // result.config is the parsed configuration object.
    // result.filepath is the path to the config file that was found.
    // result.isEmpty is true if there was nothing to parse in the config file.
  })
  .catch((error) => {
    // Do something constructive.
  });

This PR could be what you're looking for #13

This has now been merged into master with some minor fixes. So now you can set default config in .crcfrc / crcf.config.js or package.json. https://github.com/snaerth/create-react-component-folder#set-default-config. Special thanks to @sicknarlo who made the PR