Skip to content

Commit

Permalink
add change log and license, update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Beatty committed Oct 21, 2015
1 parent 129c825 commit 80488dd
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 50 deletions.
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.0.0] - 2015-10-20
### Added
- CHANGELOG to ["make it easier for users and contributors to see precisely what notable changes have been made between each release"](http://keepachangelog.com/). Linked to from README
- LICENSE to be more explicit about what was defined in `package.json`. Linked to from README
- Testing nodejs v4 on travis-ci
- added examples of how to use dotenv in different ways

### Changed
- README has shorter description not referencing ruby gem since we don't have or want feature parity

### Removed
- Variable expansion and escaping so environment variables are encouraged to be fully orthogonal

## [1.2.0] - 2015-06-20
### Added
- Preload hook to require dotenv without including it in your code

### Changed
- clarified license to be "BSD-2-Clause" in `package.json`

### Fixed
- retain spaces in string vars

## [1.1.0] - 2015-03-31
### Added
- Silent option to silence `console.log` when `.env` missing

## [1.0.0] - 2015-03-13
### Removed
- support for multiple `.env` files. should always use one `.env` file for the current environment

[Unreleased]: https://github.com/motdotla/dotenv/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/motdotla/dotenv/compare/v1.2.0...v2.0.0
[1.2.0]: https://github.com/motdotla/dotenv/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/motdotla/dotenv/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/motdotla/dotenv/compare/v0.4.0...v1.0.0
23 changes: 23 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (c) 2015, Scott Motte
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 changes: 17 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@

<img src="https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.png" alt="dotenv" align="right" />

Dotenv loads environment variables from `.env` into `ENV` (process.env).
Dotenv is a zero-dependency module that loads environment variables from a `.env` file into [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env). Storing configuration in the environment separate from code is based on [The Twelve-Factor App](http://12factor.net/config) methodology.

[![BuildStatus](https://img.shields.io/travis/motdotla/dotenv/master.svg?style=flat-square)](https://travis-ci.org/motdotla/dotenv)
[![NPM version](https://img.shields.io/npm/v/dotenv.svg?style=flat-square)](https://www.npmjs.com/package/dotenv)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

> "Storing [configuration in the environment](http://www.12factor.net/config)
> is one of the tenets of a [twelve-factor app](http://www.12factor.net/).
> Anything that is likely to change between deployment environments–such as
> resource handles for databases or credentials for external services–should be
> extracted from the code into environment variables.
>
> But it is not always practical to set environment variables on development
> machines or continuous integration servers where multiple projects are run.
> Dotenv loads variables from a `.env` file into ENV when the environment is
> bootstrapped."
>
> [Brandon Keepers' Dotenv in Ruby](https://github.com/bkeepers/dotenv)
## Install

```bash
Expand All @@ -29,10 +16,10 @@ npm install dotenv --save

## Usage

As early as possible in your application, require and load dotenv.
As early as possible in your application, require and configure dotenv.

```javascript
require('dotenv').load();
require('dotenv').config();
```

Create a `.env` file in the root directory of your project. Add
Expand Down Expand Up @@ -74,12 +61,12 @@ $ node -r dotenv/config your_script.js dotenv_config_path=/custom/path/to/your/e

## Config

_Alias: `load`_

`config` will read your .env file, parse the contents, and assign it to
`process.env` - just like `load` does. You can additionally, pass options to
[`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env). You can additionally, pass options to
`config`.

Note: `config` and `load` are synonyms. You can pass options to either.

### Options

#### Silent
Expand Down Expand Up @@ -145,34 +132,6 @@ line'}
```
- inner quotes are maintained (think JSON) (`JSON={"foo": "bar"}` becomes `{JSON:"{\"foo\": \"bar\"}"`)

#### Expanding Variables

Basic variable expansion is supported.

```
BASIC=basic
TEST=$BASIC
```

Parsing that would result in `{BASIC: 'basic', TEST: 'basic'}`. You can escape
variables by quoting or beginning with `\` (e.g. `TEST=\$BASIC`). If the
variable is not found in the file, `process.env` is checked. Missing variables
result in an empty string.

```
BASIC=basic
TEST=$TEST
DNE=$DNE
```

```bash
TEST=example node -e 'require("dotenv").config();'
```

- `process.env.BASIC` would equal `basic`
- `process.env.TEST` would equal `example`
- `process.env.DNE` would equal `""`

## FAQ

### Should I commit my `.env` file?
Expand All @@ -192,11 +151,19 @@ No. We **strongly** recommend against having a "main" `.env` file and an "enviro
### What about variable expansion?

People have expressed interest in variable expansion [many](https://github.com/motdotla/dotenv/issues/39) [times](https://github.com/motdotla/dotenv/pull/97), and it is a problem we haven't solved. The biggest challenge is coming up with a syntax that wouldn't interfere with the randomness of other environment variables like API keys. We welcome solutions! Test cases have been added to help come up with something that's backwards compatible. In the meantime, Shell and JavaScript have their own variable expansion capabilities that are well tested and reliable.
We haven't been presented a compelling use case for expanding variables and believe it leads to env vars that are not "fully orthogonal" as [The Twelve-Factor App](http://12factor.net/config) outlines.<sup>[1](https://github.com/motdotla/dotenv/issues/39)[2](https://github.com/motdotla/dotenv/pull/97)</sup> Please open an issue if you have a compelling use case.

## Contributing Guide

See [Contributing.md](Contributing.md)

## Change Log

See [CHANGELOG.md](CHANGELOG.md)

## Contributing
## License

See [Contributing Guide](Contributing.md)
See [LICENSE](LICENSE)

## Who's using dotenv

Expand Down

0 comments on commit 80488dd

Please sign in to comment.