Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sails-js-hook-dotenv

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sails-js-hook-dotenv - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

test/sails-js-hook-config.test.js

7

CHANGELOG.md

@@ -42,1 +42,8 @@ # CHANGELOG

**Full Changelog**: https://github.com/ActuallyConnor/sails-js-hook-dotenv/compare/1.0.3...1.0.4
### 1.1.0
- Adding new config options
- Adding new tests for new config options
**Full Changelog**: https://github.com/ActuallyConnor/sails-js-hook-dotenv/compare/1.0.4...1.1.0

22

index.js

@@ -21,4 +21,22 @@ dotenv = require('dotenv')

const result = dotenv.config()
const config = {}
if (sails.config[this.configKey].path !== undefined) {
config['path'] = sails.config[this.configKey].path
}
if (sails.config[this.configKey].encoding !== undefined) {
config['encoding'] = sails.config[this.configKey].encoding
}
if (sails.config[this.configKey].debug !== undefined) {
config['debug'] = sails.config[this.configKey].debug
}
if (sails.config[this.configKey].override !== undefined) {
config['override'] = sails.config[this.configKey].override
}
const result = dotenv.config(config)
// dotenv config failed to load

@@ -28,3 +46,3 @@ if (result.error) {

if (sails.config[this.configKey].throwOnFailure) {
throw result.error
throw new Error('dotenv hook failed to load')
} else {

@@ -31,0 +49,0 @@ sails.config[this.configKey].active = false

2

package.json
{
"name": "sails-js-hook-dotenv",
"version": "1.0.4",
"version": "1.1.0",
"description": "Sails.js hook for loading .env files",

@@ -5,0 +5,0 @@ "main": "index.js",

# sails-js-hook-dotenv
[Sails JS](http://sailsjs.org) hook to load environment variables from a `.env` file using [dotenv](https://github.com/motdotla/dotenv)
[Sails JS](http://sailsjs.org) hook to load environment variables from a `.env` file
using [dotenv](https://github.com/motdotla/dotenv)

@@ -11,14 +12,19 @@ ### Installation

Start sails as you normally do (`sails lift`) and you will be able to access your environment variables using `process.env.your-variable-name`
Start sails as you normally do (`sails lift`) and you will be able to access your environment variables
using `process.env.your-variable-name`
### Configuration
You can add configuration options for this hook in `config/dotenv.js` by default. Currently, the only option is a boolean: `active`. Setting this to false will disable this hook.
You can add configuration options for this hook in `config/dotenv.js` by default. Currently, the only option is a
boolean: `active`. Setting this to false will disable this hook.
```js
module.exports.dotenv = {
default: {
/**
* Setting this to false will disable this hook
*
* Default: true
*/

@@ -28,9 +34,43 @@ active: true,

/**
* Setting this to false will cause the application
* Setting this to false will cause the application
* NOT to throw an error if the config fails to load
*
* Default: true
*/
throwOnFailure: true,
/**
* Specify a custom path if your file containing
* environment variables is located elsewhere.
*
* Default: path.resolve(process.cwd(), '.env')
*/
path: '/custom/path/to/.env',
/**
* Specify the encoding of your file containing
* environment variables.
*
* Default: utf8
*/
encoding: 'latin1',
/**
* Turn on logging to help debug why certain keys
* or values are not being set as you expect.
*
* Default: false
*/
debug: true,
/**
* Override any environment variables that have
* already been set on your machine with values
* from your .env file.
*
* Default: false
*/
override: true,
}
}

@@ -37,0 +77,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc