@nuxtjs/dotenv
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -8,2 +8,3 @@ 'use strict'; | ||
var path = require('path'); | ||
var path__default = _interopDefault(path); | ||
@@ -14,9 +15,10 @@ 'use strict'; | ||
/* | ||
* Parses a string or buffer into an object | ||
* @param {String|Buffer} src - source to be parsed | ||
* @returns {Object} | ||
* @param {(string|Buffer)} src - source to be parsed | ||
* @returns {Object} keys and values from src | ||
*/ | ||
function parse (src) { | ||
var obj = {}; | ||
const obj = {}; | ||
@@ -26,12 +28,12 @@ // convert Buffers before splitting into lines and processing | ||
// matching "KEY' and 'VAL' in 'KEY=VAL' | ||
var keyValueArr = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/); | ||
const keyValueArr = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/); | ||
// matched? | ||
if (keyValueArr != null) { | ||
var key = keyValueArr[1]; | ||
const key = keyValueArr[1]; | ||
// default undefined or missing values to empty string | ||
var value = keyValueArr[2] ? keyValueArr[2] : ''; | ||
let value = keyValueArr[2] || ''; | ||
// expand newlines in quoted values | ||
var len = value ? value.length : 0; | ||
const len = value ? value.length : 0; | ||
if (len > 0 && value.charAt(0) === '"' && value.charAt(len - 1) === '"') { | ||
@@ -64,2 +66,8 @@ value = value.replace(/\\n/gm, '\n'); | ||
var envFilePath = path.join(options.path, '/.env'); | ||
try { | ||
fs.accessSync(envFilePath, fs.constants.R_OK); | ||
} catch (err) { | ||
// file not found, just return | ||
return; | ||
} | ||
var envConfig = parse_1(fs.readFileSync(envFilePath)); | ||
@@ -66,0 +74,0 @@ |
{ | ||
"name": "@nuxtjs/dotenv", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A nuxt.js module that loads your .env file into your context options", | ||
@@ -44,7 +44,7 @@ "license": "MIT", | ||
"dependencies": { | ||
"dotenv": "^4.0.0" | ||
"dotenv": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"nuxt-module-builder": "latest" | ||
"nuxt-module-builder": "0.0.2" | ||
} | ||
} |
@@ -66,3 +66,3 @@ # nuxtjs-dotenv-module | ||
Note that this is the path to the **folder** where the `.env` file live, not the the `.env` file itself. | ||
Note that this is the path to the **folder** where the `.env` file live, not to the `.env` file itself. | ||
@@ -69,0 +69,0 @@ The path can be absolute or relative. |
@@ -1,2 +0,2 @@ | ||
import { readFileSync } from 'fs' | ||
import { readFileSync, accessSync, constants as fsconstants } from 'fs' | ||
import { join } from 'path' | ||
@@ -14,2 +14,8 @@ import { parse } from 'dotenv' | ||
const envFilePath = join(options.path, '/.env') | ||
try { | ||
accessSync(envFilePath, fsconstants.R_OK) | ||
} catch (err) { | ||
// file not found, just return | ||
return | ||
} | ||
const envConfig = parse(readFileSync(envFilePath)) | ||
@@ -16,0 +22,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
8553
87
0
+ Addeddotenv@5.0.1(transitive)
- Removeddotenv@4.0.0(transitive)
Updateddotenv@^5.0.0