From 7a73fec48a0d291871d288c6e280b436a0a13110 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 1 Sep 2020 16:47:23 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20pass=20object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/utils/writeSchema.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/core/src/utils/writeSchema.ts b/packages/core/src/utils/writeSchema.ts index 4c97ca81..08d05349 100644 --- a/packages/core/src/utils/writeSchema.ts +++ b/packages/core/src/utils/writeSchema.ts @@ -1,12 +1,19 @@ -import { exists, mkdir, writeFile } from "fs"; +import { resolve } from "path"; +import { exists, mkdirSync, writeFileSync } from "fs"; -const writeSchemaData = (location: string, content: string) => { - exists(location, (exists) => { +interface WriteSchemaData { + path: string; + content: string; + fileName: string; +} + +const writeSchemaData = ({ path, content, fileName }: WriteSchemaData) => { + exists(path, (exists) => { if (!exists) { - mkdir(location, { recursive: true }, () => {}); + mkdirSync(path, { recursive: true }); } }); - writeFile(location, content, "utf-8", () => {}); + writeFileSync(resolve(path, fileName), content); }; export { writeSchemaData };