Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

with-env

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

with-env - npm Package Compare versions

Comparing version
1.1.0
to
1.1.1
+6
-0
CHANGELOG.md
# with-env
## 1.1.1
### Patch Changes
- [`ee3e02f`](https://github.com/MatthewSH/npm-packages/commit/ee3e02fa116edf6af9839458caebad272a678eae) Thanks [@MatthewSH](https://github.com/MatthewSH)! - added npm ignore
## 1.1.0

@@ -4,0 +10,0 @@

+4
-1
{
"name": "with-env",
"version": "1.1.0",
"version": "1.1.1",
"description": "Read and then apply .env file in the working directory, assuming the .env exists",

@@ -19,2 +19,5 @@ "type": "module",

},
"publishConfig": {
"provenance": true
},
"author": {

@@ -21,0 +24,0 @@ "name": "matthewh",

> with-env@1.1.0 build /home/runner/work/npm-packages/npm-packages/packages/with-env
> pkgroll
import { readFileSync } from "node:fs";
function envApply(file) {
if (typeof file !== "string") {
envApply("./.env");
}
try {
const document = readFileSync(file).toString().split("\n");
let i = -1;
while (++i < document.length) {
if (!document[i]) {
continue;
}
const row = document[i].split(/\s*=\s*/);
// biome-ignore lint/style/noNonNullAssertion: Known to be non-null
process.env[row.shift()!] = row.join("=").replace(/['"]/g, "");
}
} catch (exception) {
throw new Error(
"The .env file could not be found or read correctly. Are you sure it is in the root directory?",
);
}
}
export default envApply;