Configuration module for use by aio-cli plugins
@adobe/aio-cli-config"">
@adobe/aio-cli-config"">
This is a nodejs module to allow management of persistant and environment variable configuration by aio-cli plugins.
The module can be added to your project with:
> yarn add aio-cli-config
or
> npm install aio-cli-config --save
Here is a snippet:
const config = require('aio-cli-config')
// set a key value
config.set('pgb.authtoken', 1234)
// reload data from files and environmental variables
config.reload()
// get all stored data
config.get()
// get data from a given key
config.get('pgb.authtoken')
// delete a key
config.delete('pgb.authtoken')
The user default location is:
depending on whether the specified environmental variables exist
Local configuration is loaded from $PWD/.aio
A local .env file is also loaded. This file can contain environmental variables
Resolving configuration is done in two steps:
Inheritance is similar to NPMRC and can be set using user file, project file and matching environment variables. Values are read and merged in the following order in increasing priority:
$ AIO_PGB_AUTHTOKEN=1234 node
> config.get('pgb.authtoken')
1234
$ AIO_PGB_AUTH__TOKEN=1234 node # use double underscores to specify an underscore
> config.get('pgb.auth_token')
1234
Contributions are welcomed! Read the Contributing Guide for more information.
This project is licensed under the Apache V2 License. See LICENSE for more information.