font-finder
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -0,1 +1,8 @@ | ||
# [1.1.0](https://github.com/princjef/font-finder/compare/v1.0.5...v1.1.0) (2020-11-26) | ||
### Features | ||
* add onFontError to list options ([#8](https://github.com/princjef/font-finder/issues/8)) ([2ec412d](https://github.com/princjef/font-finder/commit/2ec412d)) | ||
## [1.0.5](https://github.com/princjef/font-finder/compare/v1.0.4...v1.0.5) (2020-11-26) | ||
@@ -2,0 +9,0 @@ |
@@ -53,2 +53,6 @@ import * as extract from './extract'; | ||
language?: string; | ||
/** | ||
* Function to call on font loading error. Default: null | ||
*/ | ||
onFontError?: ((path: string, err: Error) => void) | null; | ||
} | ||
@@ -55,0 +59,0 @@ /** |
@@ -24,3 +24,3 @@ "use strict"; | ||
async function list(options) { | ||
const opts = Object.assign({ concurrency: 4, language: 'en' }, options); | ||
const opts = Object.assign({ concurrency: 4, language: 'en', onFontError: null }, options); | ||
// TODO: support woff, woff2, ttc | ||
@@ -35,5 +35,4 @@ const files = await get_system_fonts_1.default({ extensions: ['ttf', 'otf'] }); | ||
catch (e) { | ||
// Don't swallow language errors | ||
if (['TypeError', 'SyntaxError', 'ReferenceError', 'RangeError', 'AssertionError'].includes(e.name)) { | ||
throw e; | ||
if (opts.onFontError) { | ||
opts.onFontError(file, e); | ||
} | ||
@@ -40,0 +39,0 @@ } |
{ | ||
"name": "font-finder", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"description": "Quickly find system font names and metadata without native dependencies", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/princjef/font-finder#readme", |
@@ -65,2 +65,7 @@ import getSystemFonts from 'get-system-fonts'; | ||
language?: string; | ||
/** | ||
* Function to call on font loading error. Default: null | ||
*/ | ||
onFontError?: ((path: string, err: Error) => void) | null; | ||
} | ||
@@ -87,2 +92,3 @@ | ||
language: 'en', | ||
onFontError: null, | ||
...options | ||
@@ -101,5 +107,4 @@ }; | ||
} catch (e) { | ||
// Don't swallow language errors | ||
if (['TypeError', 'SyntaxError', 'ReferenceError', 'RangeError', 'AssertionError'].includes(e.name)) { | ||
throw e; | ||
if (opts.onFontError) { | ||
opts.onFontError(file, e); | ||
} | ||
@@ -106,0 +111,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137705
2749