Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Parse and write environment files with Node.js
CoffeeScript JavaScript
Branch: master

Merge pull request #1 from Zearin/patch-1

Add .editorconfig (v1.3.18 from bevry/base)
latest commit a15494eb9b
@balupton balupton authored

README.md

envfile

Build Status NPM version Flattr this project

Parse and write environment files (.env) with Node.js

What is an envfile?

They are generally named .env or file.env and can look like:

a=1
b:2
c = 3
d : 4

Heroku and DocPad use them

Install

Backend

  1. Install Node.js
  2. npm install --save envfile

Frontend

  1. See Browserify

Usage

Via Node.js

// Include envfile
envfile = require('envfile');

// Parse an envfile path
envfile.parseFile('file.env', function(err,obj){});  // async
result = envfile.parseFileSync('file.env');  // sync

// Parse an envfile string
envfile.parse(src, function(err,obj){});  // async
result = envfile.parseSync(src);  // sync

// Stringify a javascript object to an envfile string
envfile.stringify(obj, function(err,str){});  // async
result = envfile.stringifySync(obj);  // sync

Via the Command Line

Requires a global installation of envfile: npm install -g envfile

# envfile to JSON
echo -e "a=1\nb:2" | envfile2json > config.json

# JSON to envfile
echo '{"a":1,"b":2}' | json2envfile > config.env

History

You can discover the version history inside the History.md file

License

Licensed under the incredibly permissive MIT License
Copyright © 2013+ Bevry Pty Ltd

Something went wrong with that request. Please try again.