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.3 to 1.3.4

30

dist/cli.d.ts
/**
* Generic object.
*/
type GenericObject<T = any> = {
[key: string]: T;
};
/**
* Configuration option types.
*/
export declare enum OptionType {
boolean = 0,
number = 1,
string = 2,
object = 3,
array = 4
}
/**
* List of all Dotenv configuration options type.
*/
export declare const DotenvOptionsType: GenericObject<OptionType>;
/**
* Parse CLI parameter type.
* @param option - value to parse
* @param type - value type
* @returns parsed option
*/
export declare function parseOption(option: string | undefined, type: OptionType): any;
/**
* Run CLI Dotenv runners.
* @param runner
*/
export declare function runCli(runner: Function): void;
export declare function runCli(runner: Function): any;
export {};
//# sourceMappingURL=cli.d.ts.map

26

dist/cli.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.runCli = void 0;
exports.runCli = exports.parseOption = exports.DotenvOptionsType = exports.OptionType = void 0;
/**

@@ -14,7 +14,7 @@ * Configuration option types.

OptionType[OptionType["array"] = 4] = "array";
})(OptionType || (OptionType = {}));
})(OptionType = exports.OptionType || (exports.OptionType = {}));
/**
* List of all Dotenv configuration options type.
*/
const DotenvOptionsType = {
exports.DotenvOptionsType = {
cwd: OptionType.string,

@@ -44,5 +44,8 @@ debug: OptionType.boolean,

return option === "true";
if (type === OptionType.object) {
if (type === OptionType.object || type === OptionType.array) {
try {
return JSON.parse(option);
const result = JSON.parse(option);
if (type === OptionType.array)
return Object.values(result);
return result;
}

@@ -55,2 +58,3 @@ catch (e) {

}
exports.parseOption = parseOption;
/**

@@ -64,6 +68,6 @@ * Run CLI Dotenv runners.

// Environment configuration
Object.keys(DotenvOptionsType).forEach((option) => {
Object.keys(exports.DotenvOptionsType).forEach((option) => {
const envName = "DOTENV_CONFIG_" + option.toUpperCase();
if (process.env[envName] != null) {
options[option] = parseOption(process.env[envName], DotenvOptionsType[option]);
options[option] = parseOption(process.env[envName], exports.DotenvOptionsType[option]);
}

@@ -73,4 +77,4 @@ });

const args = process.argv;
const keys = Object.keys(options).join("|");
const re = new RegExp(`^dotenv_config_(${keys})=(.+)$`, "g");
const keys = Object.keys(exports.DotenvOptionsType).join("|");
const re = new RegExp(`^dotenv_config_(${keys})=(.*?)$`, "g");
const cliOptions = args.reduce(function (opts, cur) {

@@ -81,3 +85,3 @@ const matches = cur.match(re);

const match = String(matches[2]).trim();
opts[option] = parseOption(match, DotenvOptionsType[option]);
opts[option] = parseOption(match, exports.DotenvOptionsType[option]);
}

@@ -87,5 +91,5 @@ return opts;

// Run command
runner(Object.assign(Object.assign({}, options), cliOptions));
return runner(Object.assign(Object.assign({}, options), cliOptions));
}
exports.runCli = runCli;
//# sourceMappingURL=cli.js.map

@@ -16,3 +16,3 @@ "use strict";

};
var _Dotenv__cwd, _Dotenv__debug, _Dotenv__defaults, _Dotenv__depth, _Dotenv__encoding, _Dotenv__expand, _Dotenv__override, _Dotenv__priorities, _Dotenv__nodeEnv;
var _Dotenv__cwd, _Dotenv__debug, _Dotenv__defaults, _Dotenv__depth, _Dotenv__encoding, _Dotenv__expand, _Dotenv__override, _Dotenv__priorities;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -54,3 +54,2 @@ exports.config = exports.dotenvConfig = exports.load = exports.dotenvLoad = exports.Dotenv = void 0;

_Dotenv__priorities.set(this, {});
_Dotenv__nodeEnv.set(this, "");
this.cwd = cwd;

@@ -173,3 +172,12 @@ this.debug = debug;

get priorities() {
return __classPrivateFieldGet(this, _Dotenv__priorities, "f");
var _a;
const nodeEnv = (_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : "development";
const ext = this.extension ? `.${this.extension}` : "";
const priorities = Object.assign({
[`.env${ext}.${nodeEnv}.local`]: 75,
[`.env${ext}.local`]: 50,
[`.env${ext}.${nodeEnv}`]: 25,
[`.env${ext}`]: 1,
}, __classPrivateFieldGet(this, _Dotenv__priorities, "f"));
return priorities;
}

@@ -181,11 +189,4 @@ /**

set priorities(value) {
var _a;
__classPrivateFieldSet(this, _Dotenv__nodeEnv, (_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : "development", "f");
const ext = this.extension ? `.${this.extension}` : "";
__classPrivateFieldSet(this, _Dotenv__priorities, Object.assign({
[`.env${ext}.${__classPrivateFieldGet(this, _Dotenv__nodeEnv, "f")}.local`]: 75,
[`.env${ext}.local`]: 50,
[`.env${ext}.${__classPrivateFieldGet(this, _Dotenv__nodeEnv, "f")}`]: 25,
[`.env${ext}`]: 1,
}, value !== null && value !== void 0 ? value : {}), "f");
if (value != null)
__classPrivateFieldSet(this, _Dotenv__priorities, value, "f");
}

@@ -342,3 +343,5 @@ /**

save(changes) {
if (!this.plain || !this.path)
var _a;
const file = (_a = this.path) !== null && _a !== void 0 ? _a : this.find();
if (!file || !fs_1.default.existsSync(file))
return this;

@@ -391,5 +394,6 @@ // https://github.com/stevenvachon/edit-dotenv

}, this.plain);
fs_1.default.writeFileSync(this.path, data, {
fs_1.default.writeFileSync(file, data, {
encoding: this.encoding,
});
this.plain = data;
return this;

@@ -407,3 +411,3 @@ }

exports.Dotenv = Dotenv;
_Dotenv__cwd = new WeakMap(), _Dotenv__debug = new WeakMap(), _Dotenv__defaults = new WeakMap(), _Dotenv__depth = new WeakMap(), _Dotenv__encoding = new WeakMap(), _Dotenv__expand = new WeakMap(), _Dotenv__override = new WeakMap(), _Dotenv__priorities = new WeakMap(), _Dotenv__nodeEnv = new WeakMap();
_Dotenv__cwd = new WeakMap(), _Dotenv__debug = new WeakMap(), _Dotenv__defaults = new WeakMap(), _Dotenv__depth = new WeakMap(), _Dotenv__encoding = new WeakMap(), _Dotenv__expand = new WeakMap(), _Dotenv__override = new WeakMap(), _Dotenv__priorities = new WeakMap();
/**

@@ -410,0 +414,0 @@ * Load dotenv on process and return instance of Dotenv.

{
"name": "dotenv-mono",
"version": "1.3.3",
"version": "1.3.4",
"main": "./dist/index.js",

@@ -34,3 +34,4 @@ "module": "./dist/index.js",

"prepare": "tsc",
"test": "jest"
"test": "jest",
"coverage": "jest --coverage"
},

@@ -119,4 +120,7 @@ "dependencies": {

"default",
"defaults"
"defaults",
"cli",
"console",
"preload"
]
}

@@ -251,3 +251,3 @@ <div align="center">

As on the [dotenv](https://github.com/motdotla/dotenv) package, you can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#-r---require-module) to preload dotenv. By doing this, you do not need to require and load dotenv in your application code.
As on the [dotenv](https://github.com/motdotla/dotenv) package on the CLI/Console, you can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#-r---require-module) to preload dotenv. By doing this, you do not need to require and load dotenv in your application code.

@@ -316,2 +316,4 @@ ```bash

> Note: If `.env.defaults` is present, it won't be overwritten, you can just save the changes on the main dotenv file (`.env`, `.env.local`, etc...)
```

@@ -318,0 +320,0 @@ public save(changes: Record<string, any>): Dotenv;

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