Skip to content

Commit

Permalink
style: run formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuhito committed Mar 5, 2023
1 parent 0f90b4b commit c88d558
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/api-parser-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { dirname, join } from 'pathe';
import { compile } from 'stylis';

import { apiv2 as userAgents } from '../data/user-agents.json';
import type { } from './api-gen';
import { APIDirect, APIv2 } from './data';
import type { APIResponse, FontObjectV2 } from './types';
import { orderObject, weightListGen } from './utils';
Expand Down
11 changes: 9 additions & 2 deletions src/axis-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import got from 'got';
import stringify from 'json-stringify-pretty-compact';
import * as fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import {dirname,join} from 'pathe';
import { dirname, join } from 'pathe';

interface AxisProto {
name: string;
Expand Down Expand Up @@ -59,7 +59,14 @@ const getDirectory = async (key?: string) => {
const downloadAxis = async (axis: AxisProto): Promise<AxisObject> => {
const response = await got(axis.download_url).text();

const acceptedTags = new Set(['tag', 'display_name', 'min_value', 'max_value', 'default_value', 'precision']);
const acceptedTags = new Set([
'tag',
'display_name',
'min_value',
'max_value',
'default_value',
'precision',
]);

const lines = response.split('\n').filter((line) => {
const tag = line.split(':')[0].trim();
Expand Down
8 changes: 7 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ cli
await parseLicenses();
}

if (!options.v1 && !options.v2 && !options.variable && !options.license && !options.axisRegistry) {
if (
!options.v1 &&
!options.v2 &&
!options.variable &&
!options.license &&
!options.axisRegistry
) {
if (options.force) {
consola.info(
`Parsing all metadata... ${colors.bold(colors.red('[FORCE]'))}`
Expand Down
20 changes: 14 additions & 6 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,24 @@ const APILicense = JSON.parse(
) as Licenses;

/**
* This returns the axis registry of the supported Google Font variable axes.
* {@link https://github.com/googlefonts/axisregistry}
*
* @remarks This can be updated using `npx gfm parse --registry`.
*/
* This returns the axis registry of the supported Google Font variable axes.
* {@link https://github.com/googlefonts/axisregistry}
*
* @remarks This can be updated using `npx gfm parse --registry`.
*/
const APIRegistry = JSON.parse(
fs.readFileSync(
join(dirname(fileURLToPath(import.meta.url)), '../data/axis-registry.json'),
'utf8'
)
) as AxesObject[];

export { APIDirect, APILicense, APIRegistry,APIv1, APIv2, APIVariable, APIVariableDirect };
export {
APIDirect,
APILicense,
APIRegistry,
APIv1,
APIv2,
APIVariable,
APIVariableDirect,
};
5 changes: 4 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export interface AxesObject {
export const getAxes = () => {
const data = JSON.parse(
fs.readFileSync(
join(dirname(fileURLToPath(import.meta.url)), '../data/axis-registry.json'),
join(
dirname(fileURLToPath(import.meta.url)),
'../data/axis-registry.json'
),
'utf8'
)
) as AxesObject[];
Expand Down
1 change: 0 additions & 1 deletion tests/api-parser-v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('API Parser v2', () => {
describe('Process CSS', () => {
it('Returns valid font object', async () => {
for (const font of APIResponse) {

const css = await fetchAllCSS(font);
expect(processCSS(css, font)).toMatchSnapshot();
}
Expand Down

0 comments on commit c88d558

Please sign in to comment.