Giter Site home page Giter Site logo

node-bash.env's Introduction

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='[email protected]'
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='[email protected]'

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');
```



node-bash.env's People

Contributors

tdantas avatar

Stargazers

Joe Palala avatar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.