Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
This is an environment file and value parsing piece of npm package. It aims to replace dotenv for me and anyone eager and brave enough to use it. It supports many features I missed.
The default export of this module is a function named env that takes an object with either file
or content
as field, where file
must be a path and content
must be either an utf8 Buffer
or a string
.
I build this, because dotenv does not support following:
TEST1=sgnirts driew tcelloc I
TEST2=I collect weird strings $TEST1
Or following:
HOME="$HOME$USERPOFILE"
This might not be cool but it's possible.
It does following:
env({file: "/path/"});
or
env({content: "TEST=true"});
or
env({content: Buffer.from([106, 117, 115, 116, 107, 105, 100, 100, 105, 110, 103, 61, 116, 104, 105, 115, 105, 115, 110, 111, 114, 101, 97, 108, 101, 120, 97, 109, 112, 108, 101])});
Mind the d.ts:
export default function env({file, content}: {
file?: string;
content?: string | Buffer;
}): Promise<Map<string, string>>;
Examples:
const {env} = require("x3-env");
env({content:"IWANTTHISVAR=ichangedmymind"});
console.log(`I want following value: ${process.env("IWANTTHISVAR")}`);
Or
/**
* .env.bootstrap content is:
* HOME=$HOME$USERPROFILE
* LOCAL_NOT_FOUND_ERROR=".env.local was not found
* Please create $HOME/.env.local!"
*/
const {env} = require("x3-env");
const { existsSync } = require("fs");
const { join } = require("path");
env({ file: join(__dirname, ".env.bootstrap") });
if (existsSync(join(process.env["HOME"], ".env")))
env({ file: join(process.env["HOME"], ".env") })
else
throw new Error(process.env["LOCAL_NOT_FOUND_ERROR"]);
FAQs
A env file reader written in Typescript.
The npm package x3-env receives a total of 1 weekly downloads. As such, x3-env popularity was classified as not popular.
We found that x3-env demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.