Skip to content

Commit

Permalink
fix: make it all terrible but work
Browse files Browse the repository at this point in the history
  • Loading branch information
ham-zeal committed Sep 15, 2021
1 parent 879d242 commit de71706
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "cfonts",
"name": "@zeal-corp/cfonts",
"description": "Sexy fonts for the console",
"version": "2.9.3",
"version": "2.9.9",
"types": "lib/index.d.ts",
"homepage": "https://github.com/dominikwilkowski/cfonts",
"author": {
"name": "Dominik Wilkowski",
Expand Down Expand Up @@ -30,7 +31,7 @@
"node": ">=10"
},
"scripts": {
"prepublish": "yarn build && yarn test",
"prepublish": "yarn build && yarn test && yarn types:declaration",
"test": "yarn build && yarn test:unit && yarn test:lint && yarn test:types && yarn test:fonts",
"test:fonts": "node ./test/fonttest.js",
"test:watch": "jest --watchAll --coverage",
Expand Down
38 changes: 24 additions & 14 deletions src/GetFont.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,23 @@
*
**************************************************************************************************************************************************************/

'use strict';

const { Debugging } = require('./Debugging.js');

"use strict";

const { Debugging } = require("./Debugging.js");
const d3 = require(`../fonts/3d.json`);
const block = require(`../fonts/block.json`);
const chrome = require(`../fonts/chrome.json`);
const grid = require(`../fonts/grid.json`);
const huge = require(`../fonts/huge.json`);
const pallet = require(`../fonts/pallet.json`);
const shade = require(`../fonts/shade.json`);
const simple = require(`../fonts/simple.json`);
const simple3d = require(`../fonts/simple3d.json`);
const simpleBlock = require(`../fonts/simpleBlock.json`);
const slick = require(`../fonts/slick.json`);
const tiny = require(`../fonts/tiny.json`);

const FONT_HOLSTER = { "3d": d3, block, chrome, grid, huge, pallet, shade, simple, simple3d, simpleBlock, slick, tiny };

/**
* Get a selected JSON font-file object
Expand All @@ -25,25 +38,22 @@ const { Debugging } = require('./Debugging.js');
*
* @return {object} - The font object of that file
*/
const GetFont = ( font ) => {
Debugging.report( `Running GetFont`, 1 );
const GetFont = (font) => {
Debugging.report(`Running GetFont`, 1);

// try loading the font file
try {
let FONTFACE = require(`../fonts/${ font }.json`); // read font file

Debugging.report( `GetFont: Fontface path selected: "${ font }.json"`, 2 );

let FONTFACE = FONT_HOLSTER[font]; // read font file
Debugging.report(`GetFont: Fontface path selected: "${font}.json"`, 2);
if (!FONTFACE) return false;
return FONTFACE;
}
catch( error ) {
Debugging.error( `Font file for "${ font }" errored out: ${ error }`, 2 );
} catch (error) {
Debugging.error(`Font file for "${font}" errored out: ${error}`, 2);

return false;
}
};


module.exports = exports = {
GetFont,
};

0 comments on commit de71706

Please sign in to comment.