Files
gulp-haxetool/src/common/env.ts
T
shmyga fc7f97b520
test / test (push) Failing after 31m39s
refactor(env): refactor env module
2026-10-27 01:18:23 +03:00

26 lines
578 B
TypeScript
Executable File

import path from "path";
export class Env {
constructor(private target: Record<string, string | undefined>) {}
set(key: string, value: string) {
this.target[key] = value;
}
get(key: string) {
return this.target[key];
}
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;