haz-cli
Version:
34 lines (33 loc) • 1.04 kB
JavaScript
import * as fs from "node:fs";
import { parse } from "yaml";
export default class Env {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
env;
constructor() {
this.env = parse(fs.readFileSync(process.cwd() + '/.haz', 'utf8'));
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static docker(container) {
return new Env().docker(container);
}
static dockerComposeFile() {
return new Env().dockerComposeFile();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static get(key) {
return new Env().get(key);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
docker(container) {
return this.env.docker[container];
}
dockerComposeFile() {
return this.env.dockerComposeFile || 'docker-compose.yml';
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
get(key) {
if (key === '')
return this.env;
return this.env[key];
}
}