Skip to content

Commit

Permalink
add TypeScript types (#345)
Browse files Browse the repository at this point in the history
* add TypeScript types

* mv windows testing to travis, cache dependencies, only check types once

* fix windows builds by quoting node verisons

* add back (improved) appveyor.yml

* allow windows to fail on travis until secrets properly supported

* only test current and future lts versions of node on appveyor

* add additional tsconfig for default imports

* 6.2.0-rc1

* keep typescript types in @types/dotenv
  • Loading branch information
maxbeatty committed Nov 1, 2018
1 parent 194c98e commit 1f84ba1
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Expand Up @@ -20,4 +20,4 @@ untyped-import
untyped-type-import

[version]
^0.82.0
^0.84.0
2 changes: 2 additions & 0 deletions .npmignore
@@ -1,6 +1,8 @@
.nyc_output/
flow-typed/
tests/
.editorconfig
.flowconfig
.npmignore
.travis.yml
appveyor.yml
Expand Down
24 changes: 20 additions & 4 deletions .travis.yml
@@ -1,7 +1,23 @@
language: node_js

sudo: false

os:
- linux
- windows

node_js:
- 6
- 8
- 9
- 10
- "6"
- "8"
- "9"
- "10"
- "11"

cache: npm

matrix:
fast_finish: true
allow_failures:
- os: windows

after_success: if [[ "$TRAVIS_OS_NAME" != 'windows' ]]; then npm run flow; fi
9 changes: 4 additions & 5 deletions README.md
Expand Up @@ -91,8 +91,7 @@ You can additionally, pass options to `config`.

Default: `path.resolve(process.cwd(), '.env')`

You may specify a custom path if your file containing environment variables is
named or located differently.
You may specify a custom path if your file containing environment variables is located elsewhere.

```js
require('dotenv').config({ path: '/full/custom/path/to/your/env/vars' })
Expand All @@ -102,8 +101,7 @@ require('dotenv').config({ path: '/full/custom/path/to/your/env/vars' })

Default: `utf8`

You may specify the encoding of your file containing environment variables
using this option.
You may specify the encoding of your file containing environment variables.

```js
require('dotenv').config({ encoding: 'base64' })
Expand Down Expand Up @@ -163,6 +161,7 @@ The parsing engine currently supports the following rules:
{MULTILINE: 'new
line'}
```

- inner quotes are maintained (think JSON) (`JSON={"foo": "bar"}` becomes `{JSON:"{\"foo\": \"bar\"}"`)
- whitespace is removed from both ends of the value (see more on [`trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)) (`FOO=" some value "` becomes `{FOO: 'some value'}`)

Expand Down Expand Up @@ -193,7 +192,7 @@ If you want to override `process.env` you can do something like this:
const fs = require('fs')
const dotenv = require('dotenv')
const envConfig = dotenv.parse(fs.readFileSync('.env.override'))
for (var k in envConfig) {
for (let k in envConfig) {
process.env[k] = envConfig[k]
}
```
Expand Down
33 changes: 29 additions & 4 deletions appveyor.yml
@@ -1,13 +1,38 @@
version: "{build}"
build: off
# http://www.appveyor.com/docs/appveyor-yml

# Test against these versions of Node.js.
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "9"
- nodejs_version: "10"

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node 0.STABLE.latest
- ps: Install-Product node $env:nodejs_version
# Typical npm stuff.
- npm i -g npm@latest
- npm install

# Post-install test scripts.
test_script:
- npm test
# Output useful info for debugging.
- node --version
- npm --version
- cmd: npm t

cache:
- node_modules

os:
- Default Azure

# Don't actually build using MSBuild
build: off

# Set build version format here instead of in the admin panel.
version: "{build}"

matrix:
fast_finish: true
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions package.json
@@ -1,15 +1,14 @@
{
"name": "dotenv",
"version": "6.1.0",
"version": "6.2.0-rc1",
"description": "Loads environment variables from .env file",
"main": "lib/main.js",
"scripts": {
"flow": "flow",
"pretest": "npm run lint",
"test": "tap tests/*.js --100",
"lint": "standard",
"postlint": "npm run lint-md",
"lint-md": "standard-markdown"
"postlint": "standard-markdown",
"pretest": "npm run lint",
"test": "tap tests/*.js --100"
},
"repository": {
"type": "git",
Expand All @@ -27,7 +26,7 @@
"readmeFilename": "README.md",
"license": "BSD-2-Clause",
"devDependencies": {
"flow-bin": "^0.82.0",
"flow-bin": "^0.84.0",
"sinon": "^6.3.5",
"standard": "^12.0.1",
"standard-markdown": "^5.0.1",
Expand Down

0 comments on commit 1f84ba1

Please sign in to comment.