refactor(env): refactor env module
test / test (push) Failing after 31m39s

This commit is contained in:
2026-10-27 01:18:23 +03:00
parent cf3a707a47
commit fc7f97b520
6 changed files with 33 additions and 27 deletions
+15 -9
View File
@@ -1,19 +1,25 @@
import path from "path";
export class Env {
static set(key: string, value: string) {
process.env[key] = value;
constructor(private target: Record<string, string | undefined>) {}
set(key: string, value: string) {
this.target[key] = value;
}
static get(key: string) {
return process.env[key];
get(key: string) {
return this.target[key];
}
static addPath(value: string, key = "PATH") {
if (!process.env[key]) {
process.env[key] = value;
} else if (process.env[key].split(path.delimiter).indexOf(value) === -1) {
process.env[key] = [process.env[key], value].join(path.delimiter);
addPath(value: string, key: string = "PATH") {
if (!this.target[key]) {
this.target[key] = value;
} else if (this.target[key].split(path.delimiter).indexOf(value) === -1) {
this.target[key] = [this.target[key], value].join(path.delimiter);
}
}
}
export const env = new Env(process.env);
export default env;