1.0.4 • Published 3 years ago

node-autopath-config v1.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago

node-autopath-config

Auto check for pathes as ~, /etc/, ./ in turn, and load config content.

Install

npm install node-autopath-config

Usage

const {loadConfig} = require('node-autopath-config');
const myConfig = loadConfig(myConfigPath);

myConfigPath is the config file/dir's path, which could be following options, and loadConfig() will return the content of config.

Absolute path

myConfigPath = /usr/local/etc/myconfig.js

will check:

  • /usr/local/etc/myconfig.js

Relative path

myConfigPath = myconfig.js

will check:

  • ~/.myconfig.js
  • /etc/myconfig.js
  • ./myconfig.js

Relative path with dir

myConfigPath = myproject/myconfig.js

will check:

  • ~/.myproject/myconfig.js
  • /etc/myproject/myconfig.js
  • ./myproject/myconfig.js

Relative path with prefixed dot

myConfigPath = .config/myconfig.js

will check:

  • ~/.config/myconfig.js
  • /etc/.config/myconfig.js
  • ./.config/myconfig.js
1.0.4

3 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.0

5 years ago