Skip to content
/ cenv Public

Get your environment variables directly from the cloud ☁️

License

Notifications You must be signed in to change notification settings

rodrigogs/cenv

Repository files navigation

cenv ☁️

Build Status Code Climate Test Coverage Dependency Status devDependency Status npm npm version

Load environment variables from the cloud, using the cenv-registry. cenv may be used as a cli tool from a terminal to load an environment against a command, or as a library in your Node.js application to load your environment dynamically.

Install

$ npm install cenv

Usage

  Usage: cenv [options] <environment> <command...>


  Options:

    -V, --version                  output the version number
    -f, --file [file_path]         Config file path
    -r, --registry [registry_url]  Registry url
    -u, --username [username]      Registry username
    -p, --password [password]      Registry password
    -t, --token [token]            Registry authenticated token
    -o, --timeout [timeout]        Registry connection timeout
    -h, --help                     output usage information

Registry


cenv depends on it's registry to work. You can download and configure your own registry following the instructions in this repository.

Arguments


  • *environment - Environment to retrieve from the registry
  • *command - Command that will be executed after the environment is loaded

Options


  • -V, --version - Output the version number
  • -f, --file [file_path] - Sets the config file path
    • Defaults to .cenv
    • cenv can read the config from json, yaml or ini files
    • Use false as the file path to disable loading config from file
  • -r, --registry [registry_url] - Sets the cenv-registry url
    • This option overwrites config file registry
  • -u, --username [username] - Sets registry username
    • This option overwrites config file username
  • -p, --password [password] - Sets registry password
    • This option overwrites config file password
  • -t, --token [token] - Sets registry authenticated token
    • This option overwrites config file token
  • -o, --timeout [timeout] - Sets registry request timeout in milliseconds
    • Defaults to 1000
    • This option overwrites config file timeout
  • -h, --help [timeout] - Output usage information

Examples

As cli


Usage

As lib


const cenv = require('cenv');

// cenv returns a promise, so you can wait for the environment to be loaded
cenv('myenv', { file: '../.cenv.yml' })
  .then(() => {
    console.log(process.env.myenv); // myvalue
  });

// You can also set an interval to update your application's environment from time to time
setInterval(() => cenv('anotherenv', { file: '../.cenv.json' }), 300000);

License

Licence © Rodrigo Gomes da Silva

About

Get your environment variables directly from the cloud ☁️

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published