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

babel-plugin-dotenv

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-dotenv - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

test/fixtures/filename/.babelrc

9

index.js

@@ -18,6 +18,9 @@ var dotEnv = require('dotenv');

var configDir = options.configDir ? options.configDir : './';
var configFile = options.filename ? options.filename : '.env';
if (path.node.source.value === options.replacedModuleName) {
var config = dotEnv.config({ path: sysPath.join(configDir, '.env'), silent: true }) || {};
var platformPath = (process.env.BABEL_ENV === 'development' || process.env.BABEL_ENV === undefined) ? '.env.development' : '.env.production';
var config = dotEnv.config({ path: sysPath.join(configDir, configFile), silent: true }) || {};
var platformPath = (process.env.BABEL_ENV === 'development' || process.env.BABEL_ENV === undefined)
? configFile + '.development'
: configFile + '.production';
var config = Object.assign(config, dotEnv.config({ path: sysPath.join(configDir, platformPath), silent: true }));

@@ -33,3 +36,3 @@

if(!config[importedId]) {
throw path.get('specifiers')[idx].buildCodeFrameError('Try to import dotenv variable "' + importedId + '" which is not defined in any .env files.')
throw path.get('specifiers')[idx].buildCodeFrameError('Try to import dotenv variable "' + importedId + '" which is not defined in any ' + configFile + ' files.')
}

@@ -36,0 +39,0 @@

{
"name": "babel-plugin-dotenv",
"version": "0.0.2",
"version": "0.1.0",
"description": "Load environment variables from .env file using import statement",

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

@@ -40,2 +40,7 @@ var babel = require("babel-core");

it('should load custom env file "build.env" and its overwrites', function(){
var result = babel.transformFileSync('test/fixtures/filename/source.js')
expect(result.code).to.be('\'use strict\';\n\nconsole.log(\'abc123456\');\nconsole.log(\'userdonthavename123456\');')
})
it('should load let .env.production overwrite .env', function(){

@@ -42,0 +47,0 @@ process.env['BABEL_ENV'] = 'production';

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