Skip to content

Commit

Permalink
hide summary if there's no font to download
Browse files Browse the repository at this point in the history
  • Loading branch information
0xb4lint committed Apr 9, 2023
1 parent 33f3710 commit dfa0f73
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,21 @@ function viteWebfontDownload(

if (allWebfontUrls.size) {
cssContent += await cssLoader.loadAll(allWebfontUrls, !!viteDevServer);
}

if (!viteDevServer) {
logger.info(
colors.green('✓') + ' ' +
allWebfontUrls.size.toString() + ' webfont css downloaded. ' +
colors.dim('(' +
colors.bold(toDuration(started)) + ', ' +
(options.cache !== false ?
`cache hit: ${colors.bold(toPercent(fileCache.hits.css, allWebfontUrls.size))}` :
'cache disabled'
) +
')'),
false
);
if (!viteDevServer) {
logger.info(
colors.green('✓') + ' ' +
allWebfontUrls.size.toString() + ' webfont css downloaded. ' +
colors.dim('(' +
colors.bold(toDuration(started)) + ', ' +
(options.cache !== false ?
`cache hit: ${colors.bold(toPercent(fileCache.hits.css, allWebfontUrls.size))}` :
'cache disabled'
) +
')'),
false
);
}
}

return cssContent;
Expand Down Expand Up @@ -172,18 +172,20 @@ function viteWebfontDownload(
);
}

logger.info(
colors.green('✓') + ' ' +
Object.keys(fonts).length.toString() + ' webfonts downloaded. ' +
colors.dim('(' +
colors.bold(toDuration(started)) + ', ' +
(options.cache !== false ?
`cache hit: ${colors.bold(toPercent(fileCache.hits.font, Object.keys(fonts).length))}` :
'cache disabled'
) +
')'),
false
);
if (Object.keys(fonts).length) {
logger.info(
colors.green('✓') + ' ' +
Object.keys(fonts).length.toString() + ' webfonts downloaded. ' +
colors.dim('(' +
colors.bold(toDuration(started)) + ', ' +
(options.cache !== false ?
`cache hit: ${colors.bold(toPercent(fileCache.hits.font, Object.keys(fonts).length))}` :
'cache disabled'
) +
')'),
false
);
}
};

const downloadFont = async (url: string): Promise<Buffer> => {
Expand Down

0 comments on commit dfa0f73

Please sign in to comment.