From bdf3cfc41d90f232bea1eba09e20808bc7fb7fa3 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Mon, 31 Aug 2020 12:08:58 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=88=20Schema=20util?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/round/src/utils/schema.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/round/src/utils/schema.ts b/packages/round/src/utils/schema.ts index c958bac7..8c81b576 100644 --- a/packages/round/src/utils/schema.ts +++ b/packages/round/src/utils/schema.ts @@ -1,9 +1,14 @@ import fs from "fs"; import path from "path"; -import { staticCursors, animatedCursors } from "../cursors.json"; import { baseKeyColor, outlineKeyColor, watchKeyColor } from "../color"; -import { rawSvgsDir, schemesPath, bitmapsPath } from "../config"; +import { + rawSvgsDir, + schemesPath, + bitmapsPath, + animatedCursors, + staticCursors +} from "../config"; import { ColorSchema, Config } from "../types"; // --------------------------------------- Generate Configs 🛠 @@ -23,22 +28,21 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => { fs.mkdirSync(schemaSvgsPath, { recursive: true }); const { base, outline, watch } = colorSchemes[schema]; - staticCursors.map((cursor: string) => { + + staticCursors.forEach((cursor: string) => { // Read file - let content = fs - .readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8") - .toString(); + let content = fs.readFileSync(cursor, "utf-8").toString(); content = content .replace(new RegExp(baseKeyColor, "g"), base) .replace(new RegExp(outlineKeyColor, "g"), outline); // Save Schema - const cursorPath = path.resolve(schemaSvgsPath, cursor); + const cursorPath = path.resolve(schemaSvgsPath, "static", cursor); fs.writeFileSync(cursorPath, content, "utf-8"); }); - for (let [cursor] of Object.entries(animatedCursors)) { + animatedCursors.forEach((cursor: string) => { // Read file let content = fs .readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8") @@ -63,9 +67,9 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => { } // Save Schema - const cursorPath = path.resolve(schemaSvgsPath, cursor); + const cursorPath = path.resolve(schemaSvgsPath, "animated", cursor); fs.writeFileSync(cursorPath, content, "utf-8"); - } + }); // Creating Dir for store bitmaps const bitmapsDir = path.resolve(bitmapsPath, schemaName); @@ -73,7 +77,6 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => { // push config to Object configs[schema] = { - svgsDir: schemaSvgsPath, bitmapsDir, animatedCursors, staticCursors