Skip to content

Commit

Permalink
node-emoji (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgeorgegray authored Feb 22, 2021
1 parent a0aeb8e commit def1840
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
46 changes: 44 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
"cache-manager": "^3.4.0",
"cache-manager-fs-hash": "^0.0.9",
"cli-table3": "^0.6.0",
"node-emoji": "^1.10.0",
"yargs": "^15.4.1"
},
"devDependencies": {
"@types/cache-manager": "^3.4.0",
"@types/jest": "^26.0.20",
"@types/node-emoji": "^1.8.1",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"axios-mock-adapter": "^1.19.0",
Expand Down
18 changes: 13 additions & 5 deletions src/drawTable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Table from "cli-table3";
import emoji from "node-emoji";

import formatTime from "./formatTime";
import formatDayLength from "./formatDayLength";
Expand All @@ -16,6 +17,13 @@ const drawTable = ({
style: { border: ["gray"] },
});

const onMissing = () => "*";
const dawnEmoji = emoji.emojify(":sunrise:", onMissing);
const sunriseEmoji = emoji.emojify(":sunglasses:", onMissing);
const sunsetEmoji = emoji.emojify(":city_sunset:", onMissing);
const duskEmoji = emoji.emojify(":vampire:", onMissing);
const lengthEmoji = emoji.emojify(":stopwatch:", onMissing);

table.push(
[
{
Expand All @@ -24,11 +32,11 @@ const drawTable = ({
content: `dawn-till-dusk for '${date}'`,
},
],
{ "🌅": ["Dawn", formatTime(civil_twilight_begin)] },
{ "😎": ["Sunrise", formatTime(sunrise)] },
{ "🌇": ["Sunset", formatTime(sunset)] },
{ "🧛": ["Dusk", formatTime(civil_twilight_end)] },
{ "⏱": ["Length", formatDayLength(day_length)] }
{ [dawnEmoji]: ["Dawn", formatTime(civil_twilight_begin)] },
{ [sunriseEmoji]: ["Sunrise", formatTime(sunrise)] },
{ [sunsetEmoji]: ["Sunset", formatTime(sunset)] },
{ [duskEmoji]: ["Dusk", formatTime(civil_twilight_end)] },
{ [lengthEmoji]: ["Length", formatDayLength(day_length)] }
);

return table.toString();
Expand Down

0 comments on commit def1840

Please sign in to comment.