mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-20 10:15:11 -04:00
🧹 code cleanup
This commit is contained in:
parent
d59b297a8e
commit
19a7e034d8
1 changed files with 50 additions and 58 deletions
|
@ -17,76 +17,68 @@ const generateConfigs = (colorSchemes: ColorSchema, dirPrefix: string) => {
|
||||||
|
|
||||||
const configs: Configs = {};
|
const configs: Configs = {};
|
||||||
|
|
||||||
spinner.text = `Generating ${dirPrefix} Color schemes`;
|
for (let [schema] of Object.entries(colorSchemes)) {
|
||||||
spinner.start();
|
const schemaName = `${dirPrefix}-${schema}`;
|
||||||
|
|
||||||
try {
|
const schemaSvgsPath = path.resolve(schemesPath, schemaName);
|
||||||
for (let [schema] of Object.entries(colorSchemes)) {
|
fs.mkdirSync(schemaSvgsPath, { recursive: true });
|
||||||
const schemaName = `${dirPrefix}-${schema}`;
|
|
||||||
|
|
||||||
const schemaSvgsPath = path.resolve(schemesPath, schemaName);
|
const { base, outline, watch } = colorSchemes[schema];
|
||||||
fs.mkdirSync(schemaSvgsPath, { recursive: true });
|
staticCursors.map((cursor: string) => {
|
||||||
|
// Read file
|
||||||
|
let content = fs
|
||||||
|
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
||||||
|
.toString();
|
||||||
|
|
||||||
const { base, outline, watch } = colorSchemes[schema];
|
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
||||||
staticCursors.map((cursor: string) => {
|
|
||||||
// Read file
|
|
||||||
let content = fs
|
|
||||||
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
|
||||||
.toString();
|
|
||||||
|
|
||||||
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
// Save Schema
|
||||||
|
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
||||||
|
fs.writeFileSync(cursorPath, content, "utf-8");
|
||||||
|
});
|
||||||
|
|
||||||
// Save Schema
|
for (let [cursor] of Object.entries(animatedCursors)) {
|
||||||
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
// Read file
|
||||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
let content = fs
|
||||||
});
|
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
||||||
|
.toString();
|
||||||
|
|
||||||
for (let [cursor] of Object.entries(animatedCursors)) {
|
// Animated Cursors have two parts:
|
||||||
// Read file
|
// 1) Cursor Color
|
||||||
let content = fs
|
// 2) Watch Color
|
||||||
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
|
||||||
.toString();
|
|
||||||
|
|
||||||
// Animated Cursors have two parts:
|
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
||||||
// 1) Cursor Color
|
|
||||||
// 2) Watch Color
|
|
||||||
|
|
||||||
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
// try => replace `customize` colors
|
||||||
|
// onError => replace `schema` main colors
|
||||||
|
try {
|
||||||
|
if (!watch) throw new Error("");
|
||||||
|
const { background: b } = watch;
|
||||||
|
content = content.replace("#TODO", b); // Watch Background
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
// try => replace `customize` colors
|
// Save Schema
|
||||||
// onError => replace `schema` main colors
|
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
||||||
try {
|
fs.writeFileSync(cursorPath, content, "utf-8");
|
||||||
if (!watch) throw new Error("");
|
|
||||||
const { background: b } = watch;
|
|
||||||
content = content.replace("#TODO", b); // Watch Background
|
|
||||||
} catch (error) {}
|
|
||||||
|
|
||||||
// Save Schema
|
|
||||||
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
|
||||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creating Dir for store bitmaps
|
|
||||||
const bitmapsDir = path.resolve(bitmapsPath, schemaName);
|
|
||||||
fs.mkdirSync(bitmapsDir, { recursive: true });
|
|
||||||
|
|
||||||
// push config to Object
|
|
||||||
configs[schema] = {
|
|
||||||
svgsDir: schemaSvgsPath,
|
|
||||||
bitmapsDir,
|
|
||||||
animatedCursors,
|
|
||||||
staticCursors,
|
|
||||||
animatedClip
|
|
||||||
};
|
|
||||||
|
|
||||||
spinner.succeed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return configs;
|
// Creating Dir for store bitmaps
|
||||||
} catch (error) {
|
const bitmapsDir = path.resolve(bitmapsPath, schemaName);
|
||||||
spinner.fail();
|
fs.mkdirSync(bitmapsDir, { recursive: true });
|
||||||
process.exit(1);
|
|
||||||
|
// push config to Object
|
||||||
|
configs[schema] = {
|
||||||
|
svgsDir: schemaSvgsPath,
|
||||||
|
bitmapsDir,
|
||||||
|
animatedCursors,
|
||||||
|
staticCursors,
|
||||||
|
animatedClip
|
||||||
|
};
|
||||||
|
|
||||||
|
spinner.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return configs;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { generateConfigs };
|
export { generateConfigs };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue