I will try to keep this question short, but it consists of two parts:
- Where should the configuration files for nodejs / npm CLI tools be saved?
- What should they call?
Let's say I'm writing a CLI node.js tool that, for example, captures the weather today and displays it in the terminal. I call it weather-getter . Please note: the main goal is not to be called programmatically, but is entered into the terminal as BASH. It is designed to run by typing its simple name after installation around the world, or through a directory in the local / bin user. (Sudo is not required to install it.)
This project will install normally through npm. It can receive zipcode through an argument, for example:
gavin@localhost :~$ weather-getter -z "12345"
OK, the program works fine. The next step would be to allow the user to save the configuration file somewhere and pull the default configuration from this file. Like the .vimrc file. This configuration might look like this:
{ "zipcode": "12345", "language": "en", "unit": "fahrenheit" }
I suppose it should start from a point. I also suggest that it should be located in the npm module, and not in ~ /. Or should I use ~ / or / etc / or ~ / .config or ~ / .local, like so many other programs? Should node programs try to use a shared directory, for example ~ / .config / node / or ~ / .config / npm /? And if the file is there, should it start without a dot?
Note. My question is not in reading / writing a file with node.js, but only in recommendations for configuration location and naming. Thanks!
Gavin source share