config.env

1.1.0 • Public • Published

Build Status Code Climate

Suppose your upstart script is something like that

description "Simple upstart Script from my Node project"

start on started networking
stop on runlevel [016]

respawn

env MAIL_FROM='noreply@mail.com'
export MAIL_FROM

pre-start script
  . /apps/myproject/.env
end script

script
  exec /usr/bin/node /apps/simple.js
end script

The upstart section above is sourcing the /apps/myproject/.env file. this technique enable us to load the environment variables that will be used your application.

The same .env file from your application is used in the upstart/bash script.

/apps/myproject/.env

export NODE_ENV=production
export API_SECRET=1239012389084327897450-231
export VERBOSE=false
export MAIL_FORM='tdantas@email.com'

In the above snippet, MAIL_FROM was defined in the upstart script and in the configuration file [ /apps/myproject/.env ]. by default the bash.env will not override defined environment variables.

Usage

  var source = require('bash.env');
  source.load(); # will attach the .env variables to process.env

API

#load

options: Object

  path: [.env] The path to .env file.
  override: [false] if false will not override pre defined environment variable.
  loadTo: [process.env] object that will attach the definitions from config file
  
  
  var obj = {};
  source.load({ path: '/etc/app/config', override: true, loadTo: obj });
```
options: String
```
  the path to .env file
  
  
  source.load('/etc/app/config');
```



Readme

Keywords

none

Package Sidebar

Install

npm i config.env

Weekly Downloads

7

Version

1.1.0

License

ISC

Last publish

Collaborators

  • tdantas