Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move todo to issues #6

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#! /usr/bin/env node

// ToDo
// - convert to npm package
// - convert to TS
// - write unit tests
// - write screenshot tests
const path = require('path')
const fontkit = require('fontkit')
const { program } = require('commander')
Expand Down Expand Up @@ -74,9 +68,9 @@ function calculateFallbackFontValues (font, category = 'serif') {
}

program
// ToDo: add descriptions
.name('fontpie')
.description('Get your layout shifts optimized with a CLI-generated piece of CSS')
.argument('<file>', '*.ttf, *.otf, *.woff or *.woff2 font file')
// ToDo: validate options
.option(
'-f, --fallback <font-family>',
'fallback font family type: "serif" or "sans-serif"',
Expand All @@ -89,8 +83,14 @@ program
'font name what will be used as font-family value, by default font filename'
)
.action((file, option) => {
// ToDo: try...catch
const font = fontkit.openSync(file)
let font

try {
font = fontkit.openSync(file)
} catch (err) {
console.error(err.message)
return
}

const {
ascentOverride,
Expand Down