Skip to content

Commit

Permalink
Update build script messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmockett committed Mar 12, 2024
1 parent f28676b commit fa8bfc7
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import fs from 'node:fs';
import { tokens } from '@guardian/design-tokens';
import { fontArrayToString, pxStringToRem } from '../src/utils/convert-value';

const { presets } = tokens.typography;
const outputPath = `${process.cwd()}/src/typography/presets.ts`;
console.log('Building typography presets…');

const STRIP_WHITESPACE = /^\s+/gm;
const STRIP_TABS = /^\t{3}|\t{2}/gm;

const { presets } = tokens.typography;
const presetTotal = Object.keys(presets).length;
const outputPath = `${process.cwd()}/src/typography/presets.ts`;

const banner = `
// Typography presets
// Auto-generated by scripts/build-type-presets.ts
Expand All @@ -29,5 +32,5 @@ const css = Object.entries(presets)
.join('')
.replace(STRIP_TABS, '');

console.log('Writing typography presets.');
fs.writeFileSync(outputPath, banner + css);
console.log(`✓ ${presetTotal} presets built`);

0 comments on commit fa8bfc7

Please sign in to comment.