Copy from example if not exist

This commit is contained in:
2022-02-02 21:18:05 +07:00
parent 12704f9471
commit e6f09403a0
+9
View File
@@ -10,6 +10,15 @@ class Configuration {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
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));
}
}
// TODO: Make a real providers like Environment