I'm writing a CLI tool in Node and I'd like it to be configurable by a config file when it's used by a consumers project. Pretty similar to how es-lint's .eslintrc
or babel .bablerc
works.
consumer-app
node_modules
my-cli-tool
index.js ← my tool
.configfile ← configuration file for the cli tool
package.json
These files are usually placed at the root of the project and sometimes you can have multiple config files at different levels of the file tree.
consumer-app
sub-directory
.configfile ← another configuration file for this sub-dir
node_modules
my-cli-tool
index.js ← my tool
.configfile ← configuration file
package.json
What's the overall architecture of building something similar? I can have my module look for its config file - but I'm having a hard time locating those config files or the root directory of a project because that's most likely where they're going to be.