Files
Yumi/src/providers/Configuration.ts
T

29 lines
800 B
TypeScript
Raw Normal View History

2022-01-27 18:00:47 +07:00
import fs from "fs";
import path from "path";
import Logger from "../libs/Logger";
class Configuration {
public init(): void {
const dir = path.join(process.cwd(), 'configs/');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
2022-02-02 21:18:05 +07:00
this.copyExampleIfNotExists("Ping.json");
this.copyExampleIfNotExists("ServiceAnnouncement.json");
}
private copyExampleIfNotExists(file: string): void {
const dir = path.join(process.cwd(), 'configs/');
if (!fs.existsSync(path.join(dir, file))) {
fs.copyFileSync(path.join(process.cwd(), 'configs/', `${file.replace('.json', '.example.json')}`), path.join(dir, file));
}
2022-01-27 18:00:47 +07:00
}
// TODO: Make a real providers like Environment
}
export default new Configuration();