🌈 semi-animated svg messsages

This commit is contained in:
ful1e5 2020-11-12 10:31:18 +05:30
parent da072a031a
commit 7bed63cea5

View file

@ -6,6 +6,7 @@ export default class SvgDirectoryParser {
* Parse the `.svg` files directory. * Parse the `.svg` files directory.
* @param svgDir is relative/absolute path, Where source `.svg` files are stored. * @param svgDir is relative/absolute path, Where source `.svg` files are stored.
*/ */
semiAnimated: boolean = false;
constructor(private svgDir: string) { constructor(private svgDir: string) {
if (!fs.existsSync(this.svgDir)) { if (!fs.existsSync(this.svgDir)) {
throw new Error(`🚨 .svg files not found in ${this.svgDir}`); throw new Error(`🚨 .svg files not found in ${this.svgDir}`);
@ -28,6 +29,9 @@ export default class SvgDirectoryParser {
if (staticCursors.length == 0) { if (staticCursors.length == 0) {
console.warn("Static Cursors directory is empty"); console.warn("Static Cursors directory is empty");
console.log("Considering as semi-animated theme");
this.semiAnimated = true;
} }
return staticCursors; return staticCursors;
@ -47,7 +51,11 @@ export default class SvgDirectoryParser {
.readdirSync(cursorDir) .readdirSync(cursorDir)
.map((f) => path.resolve(cursorDir, f)); .map((f) => path.resolve(cursorDir, f));
if (animatedCursors.length == 0) { if (animatedCursors.length == 0 && this.semiAnimated) {
throw new Error(
`🚨 Can't parse svg directory ${this.svgDir} as semi-animated cursors`
);
} else {
console.warn("Animated Cursors directory is empty"); console.warn("Animated Cursors directory is empty");
} }