💖 spinner

This commit is contained in:
ful1e5 2020-08-19 13:01:56 +05:30
parent 780ce83c4d
commit d59b297a8e

View file

@ -1,6 +1,8 @@
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
import { spinner } from "shared";
import { staticCursors, animatedCursors, animatedClip } from "../cursors.json"; import { staticCursors, animatedCursors, animatedClip } from "../cursors.json";
import { schemesPath, bitmapsPath, rawSvgsDir } from "../color"; import { schemesPath, bitmapsPath, rawSvgsDir } from "../color";
import { ColorSchema, Configs } from "../types"; import { ColorSchema, Configs } from "../types";
@ -15,13 +17,17 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => {
const configs: Configs = {}; const configs: Configs = {};
spinner.text = `Generating ${dirPrefix} Color schemes`;
spinner.start();
try {
for (let [schema] of Object.entries(colorSchemes)) { for (let [schema] of Object.entries(colorSchemes)) {
const { base, outline, watch } = colorSchemes[schema];
const schemaName = `${dirPrefix}-${schema}`; const schemaName = `${dirPrefix}-${schema}`;
const schemaSvgsPath = path.resolve(schemesPath, schemaName); const schemaSvgsPath = path.resolve(schemesPath, schemaName);
fs.mkdirSync(schemaSvgsPath, { recursive: true }); fs.mkdirSync(schemaSvgsPath, { recursive: true });
const { base, outline, watch } = colorSchemes[schema];
staticCursors.map((cursor: string) => { staticCursors.map((cursor: string) => {
// Read file // Read file
let content = fs let content = fs
@ -72,9 +78,15 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => {
staticCursors, staticCursors,
animatedClip animatedClip
}; };
spinner.succeed();
} }
return configs; return configs;
} catch (error) {
spinner.fail();
process.exit(1);
}
}; };
export { generateConfigs }; export { generateConfigs };