New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

serverless-dotenv-plugin

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-dotenv-plugin - npm Package Compare versions

Comparing version 1.1.5 to 1.2.0

77

index.js

@@ -1,21 +0,14 @@

'use strict';
'use strict'
const fs = require('fs');
const dotenv = require('dotenv');
const dotenvExpand = require('dotenv-expand');
const chalk = require('chalk');
const dotenv = require('dotenv')
const dotenvExpand = require('dotenv-expand')
const chalk = require('chalk')
class ServerlessPlugin {
constructor(serverless, options) {
this.serverless = serverless;
this.env = {};
this.serverless.service.provider.environment = this.serverless.service.provider.environment || {};
this.hooks = {
"before:offline:start:init": this.loadEnv.bind(this),
"before:offline:start": this.loadEnv.bind(this),
"before:invoke:local:invoke": this.loadEnv.bind(this),
"before:deploy:resources": this.loadEnv.bind(this),
"before:deploy:functions": this.loadEnv.bind(this),
"before:package:initialize": this.loadEnv.bind(this),
}
this.serverless = serverless
this.env = {}
this.serverless.service.provider.environment =
this.serverless.service.provider.environment || {}
this.loadEnv()
}

@@ -25,32 +18,40 @@

try {
this.serverless.cli.log('DOTENV: Loading environment variables:');
var config = this.serverless.service.custom && this.serverless.service.custom['dotenv'];
var envPath = (config && config.path) || '.env';
this.env = dotenvExpand(dotenv.config({path: envPath})).parsed;
var config =
this.serverless.service.custom &&
this.serverless.service.custom['dotenv']
var envPath = (config && config.path) || '.env'
this.env = dotenvExpand(dotenv.config({ path: envPath })).parsed
var include = false;
var include = false
if (config && config.include) {
include = config.include;
include = config.include
}
if (include) {
Object.keys(this.env)
.filter((key) => !include.includes(key))
.forEach((key) => {
delete this.env[key]
})
if (this.env) {
this.serverless.cli.log('DOTENV: Loading environment variables:')
if (include) {
Object.keys(this.env)
.filter(key => !include.includes(key))
.forEach(key => {
delete this.env[key]
})
}
Object.keys(this.env).forEach(key => {
this.serverless.cli.log('\t - ' + key)
this.serverless.service.provider.environment[key] = this.env[key]
})
} else {
this.serverless.cli.log('DOTENV: Could no find .env file.')
}
Object.keys(this.env)
.forEach((key) => {
this.serverless.cli.log("\t - " + key);
this.serverless.service.provider.environment[key] = this.env[key];
})
} catch (e) {
console.error(chalk.red('\n Serverless Plugin Error --------------------------------------\n'))
console.error(chalk.red(' ' + e.message));
console.error(
chalk.red(
'\n Serverless Plugin Error --------------------------------------\n'
)
)
console.error(chalk.red(' ' + e.message))
}
}
}
module.exports = ServerlessPlugin;
module.exports = ServerlessPlugin
{
"name": "serverless-dotenv-plugin",
"version": "1.1.5",
"version": "1.2.0",
"description": "Preload Environment Variables with Dotenv into Serverless Edit",

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

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