Easy require property from
cwd
. Get, extend, destroy property using dot-notation
$ npm install --save req-prop
Imagine the folder structure like this.
├── code
│ └── dev-app
│ │ ├── config/setting.js
│ │ ├── lib/database/api/v1/index.js
│ │ ├── index.js
│ │ └── package.json
// ~/code/dev-app/config/setting.js
module.exports = {
app: {
name: 'unicorn'
}
};
// ~/code/dev-app/lib/database/api/v1/index.js
const reqProp = require('req-prop');
const setting = reqProp('api', './config/setting');
console.log(setting.get('api.app.name'));
# ~/code/dev-app
$ node lib/database/api/v1/index.js
# 'unicorn'
- Type
string
- Required:
true
- Type
string
- Required:
true
Set Module path
Also See dot-prop API
Extend an item.
Extend multiple items at once.
Get an item.
Check if an item exists.
Delete an item.
Delete all items.
MIT © Guntur Poetra