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

vite-plugin-env-file

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-env-file - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

index.mjs

32

index.js

@@ -1,8 +0,8 @@

import Env from '@marknotton/env'
const Env = require('@marknotton/env');
export default function updateEnvFile(envVars = {}, options = {}) {
function updateEnvFile(envVars = {}, options = {}) {
// Use default values for options if not provided
const { prefix = 'VITE_', forceUpperCase = true, envFile = 'vite.env' } = options || {}
const { prefix = 'VITE_', forceUpperCase = true, envFile = 'vite.env' } = options || {};
const envFileModule = new Env(envFile)
const envFileModule = new Env(envFile);

@@ -13,7 +13,9 @@ return {

// Do nothing if envVars is falsy
if (!envVars) return
if (!envVars) return;
// Convert keys to upper case if forceUpperCase is true
if (forceUpperCase) {
envVars = Object.fromEntries(Object.entries(envVars).map(([key, value]) => [key.toUpperCase(), value]))
envVars = Object.fromEntries(
Object.entries(envVars).map(([key, value]) => [key.toUpperCase(), value])
);
}

@@ -23,17 +25,19 @@

Object.keys(envVars).forEach((key) => {
const envKey = prefix ? `${prefix}${key}` : key
envFileModule.set(envKey, envVars[key])
})
const envKey = prefix ? `${prefix}${key}` : key;
envFileModule.set(envKey, envVars[key]);
});
},
async buildEnd() {
// Do nothing if envVars is falsy
if (!envVars) return
if (!envVars) return;
// Delete the set environment variables
Object.keys(envVars).forEach((key) => {
const envKey = prefix ? `${prefix}${key}` : key
envFileModule.delete(envKey)
})
const envKey = prefix ? `${prefix}${key}` : key;
envFileModule.delete(envKey);
});
}
}
};
}
module.exports = updateEnvFile;
{
"name": "vite-plugin-env-file",
"version": "1.0.0",
"version": "1.0.1",
"author": "Mark Notton <mark@marknotton.uk>",
"license": "MIT",
"public": true,
"main": "index.js",
"dependencies": {
"@marknotton/env": "1.1.4"
"@marknotton/env": "2.0.0"
},
"main": "index.js",
"module": "index.mjs",
"types": "index.d.ts",
"keywords": [

@@ -12,0 +14,0 @@ "vite-plugin"

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