serverless-dotenv-plugin
Advanced tools
Comparing version 2.3.2 to 2.4.2
@@ -12,3 +12,11 @@ ### Example Express App | ||
``` | ||
> NODE_ENV=production sls deploy | ||
``` | ||
or | ||
``` | ||
> sls deploy --env production | ||
``` | ||
or | ||
``` | ||
> sls deploy --stage production | ||
``` |
10
index.js
@@ -21,11 +21,3 @@ 'use strict' | ||
getEnvironment(options) { | ||
if (process.env.NODE_ENV) { | ||
return process.env.NODE_ENV | ||
} | ||
if (options.env) { | ||
return options.env | ||
} | ||
return 'development' | ||
return process.env.NODE_ENV || options.env || options.stage || 'development' | ||
} | ||
@@ -32,0 +24,0 @@ |
{ | ||
"name": "serverless-dotenv-plugin", | ||
"version": "2.3.2", | ||
"version": "2.4.2", | ||
"description": "Preload environment variables with dotenv into serverless.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -42,10 +42,13 @@ # serverless-dotenv-plugin [![npm version](https://img.shields.io/npm/v/serverless-dotenv-plugin.svg?style=flat)](https://www.npmjs.com/package/serverless-dotenv-plugin) | ||
When you deploy with `NODE_ENV` set: `NODE_ENV=production sls deploy` the plugin will look for a file named `.env.production`. If it doesn't exist it will default to `.env`. If for some reason you can't set NODE_ENV, you could always just pass it in as an option: `sls deploy --env production`. If `NODE_ENV` or `--env` is not set, it will default to `development`. | ||
When you deploy with `NODE_ENV` set: `NODE_ENV=production sls deploy` the plugin will look for a file named `.env.production`. If it doesn't exist it will default to `.env`. If for some reason you can't set NODE_ENV, you could always just pass it in as an option: `sls deploy --env production` or `sls deploy --stage production`. If `NODE_ENV`, `--env` or `--stage` is not set, it will default to `development`. | ||
| Valid .env file names | Description | | ||
| --------------------- | --------------------------------------------------------------------------------------------------- | | ||
| .env | Default file name when no other files are specified or found. | | ||
| .env.development | If NODE_ENV or --env **is not set**, will try to load `.env.development`. If not found, load `.env` | | ||
| .env.{ENV} | If NODE_ENV or --env **is set**, will try to load `.env.{env}`. If not found, load `.env` | | ||
The precedence between the options is the following: | ||
`NODE_ENV` **>** `--env` **>** `--stage` | ||
| Valid .env file names | Description | | ||
| --------------------- | ------------------------------------------------------------------------------------------------------------ | | ||
| .env | Default file name when no other files are specified or found. | | ||
| .env.development | If NODE_ENV or --env or --stage **is not set**, will try to load `.env.development`. If not found, load `.env` | | ||
| .env.{ENV} | If NODE_ENV or --env or --stage **is set**, will try to load `.env.{env}`. If not found, load `.env` | | ||
### Plugin options | ||
@@ -52,0 +55,0 @@ |
28743
130
3
167682
540