From e6f09403a037784ea5450c1faf73ae3189219522 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Wed, 2 Feb 2022 21:18:05 +0700 Subject: [PATCH] Copy from example if not exist --- src/providers/Configuration.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/providers/Configuration.ts b/src/providers/Configuration.ts index d61c738..91c1a79 100644 --- a/src/providers/Configuration.ts +++ b/src/providers/Configuration.ts @@ -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