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

dotenv-mono

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotenv-mono - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

114

dist/cli.js

@@ -5,2 +5,51 @@ "use strict";

/**
* Configuration option types.
*/
var OptionType;
(function (OptionType) {
OptionType[OptionType["boolean"] = 0] = "boolean";
OptionType[OptionType["number"] = 1] = "number";
OptionType[OptionType["string"] = 2] = "string";
OptionType[OptionType["object"] = 3] = "object";
OptionType[OptionType["array"] = 4] = "array";
})(OptionType || (OptionType = {}));
/**
* List of all Dotenv configuration options type.
*/
const DotenvOptionsType = {
cwd: OptionType.string,
debug: OptionType.boolean,
defaults: OptionType.string,
depth: OptionType.number,
encoding: OptionType.string,
expand: OptionType.boolean,
extension: OptionType.string,
path: OptionType.string,
override: OptionType.boolean,
priorities: OptionType.object,
};
/**
* Parse CLI parameter type.
* @param option - value to parse
* @param type - value type
* @returns parsed option
*/
function parseOption(option, type) {
if (option === undefined)
return option;
if (type === OptionType.number)
return Number(option);
if (type === OptionType.boolean)
return option === "true";
if (type === OptionType.object) {
try {
return JSON.parse(option);
}
catch (e) {
console.error(e);
}
}
return option;
}
/**
* Run CLI Dotenv runners.

@@ -11,50 +60,10 @@ * @param runner

// Empty options
const options = {
cwd: undefined,
debug: undefined,
defaults: undefined,
depth: undefined,
encoding: undefined,
expand: undefined,
extension: undefined,
path: undefined,
override: undefined,
priorities: undefined,
};
const options = {};
// Environment configuration
if (process.env.DOTENV_CONFIG_CWD != null) {
options.cwd = process.env.DOTENV_CONFIG_CWD;
}
if (process.env.DOTENV_CONFIG_DEBUG != null) {
options.debug = process.env.DOTENV_CONFIG_DEBUG === "true";
}
if (process.env.DOTENV_CONFIG_DEFAULTS != null) {
options.defaults = process.env.DOTENV_CONFIG_DEFAULTS;
}
if (process.env.DOTENV_CONFIG_DEPTH != null) {
options.depth = Number(process.env.DOTENV_CONFIG_DEPTH);
}
if (process.env.DOTENV_CONFIG_ENCODING != null) {
options.encoding = process.env.DOTENV_CONFIG_ENCODING;
}
if (process.env.DOTENV_CONFIG_EXPAND != null) {
options.expand = process.env.DOTENV_CONFIG_EXPAND === "true";
}
if (process.env.DOTENV_CONFIG_EXTENSION != null) {
options.extension = process.env.DOTENV_CONFIG_EXTENSION;
}
if (process.env.DOTENV_CONFIG_PATH != null) {
options.path = process.env.DOTENV_CONFIG_PATH;
}
if (process.env.DOTENV_CONFIG_OVERRIDE != null) {
options.override = process.env.DOTENV_CONFIG_OVERRIDE === "true";
}
if (process.env.DOTENV_CONFIG_PRIORITIES != null) {
try {
options.priorities = JSON.parse(process.env.DOTENV_CONFIG_PRIORITIES);
Object.keys(DotenvOptionsType).forEach((option) => {
const envName = "DOTENV_CONFIG_" + option.toUpperCase();
if (process.env[envName] != null) {
options[option] = parseOption(process.env[envName], DotenvOptionsType[option]);
}
catch (e) {
console.error(e);
}
}
});
// CLI Parameter configuration parser

@@ -64,13 +73,10 @@ const args = process.argv;

const re = new RegExp(`^dotenv_config_(${keys})=(.+)$`, "g");
const cliOptions = args.reduce(function (acc, cur) {
const cliOptions = args.reduce(function (opts, cur) {
const matches = cur.match(re);
if (matches) {
let match = String(matches[2]).trim();
const isBoolean = match === "true" || match === "false";
if (isBoolean) {
match = match === "true";
}
acc[String(matches[1])] = match;
const option = String(matches[1]).trim();
const match = String(matches[2]).trim();
opts[option] = parseOption(match, DotenvOptionsType[option]);
}
return acc;
return opts;
}, {});

@@ -77,0 +83,0 @@ // Run command

@@ -61,3 +61,3 @@ /// <reference types="node" />

*/
encoding?: BufferEncoding;
encoding?: BufferEncoding | string;
/**

@@ -142,3 +142,3 @@ * Turn on/off the dotenv-expand plugin.

*/
set encoding(value: BufferEncoding | undefined);
set encoding(value: BufferEncoding | string | undefined);
/**

@@ -145,0 +145,0 @@ * Get dotenv-expand plugin enabling.

{
"name": "dotenv-mono",
"version": "1.3.0",
"version": "1.3.1",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "module": "./dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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