@iconify/tools 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,8 +56,17 @@ function importDir(iconSet, options, getKeyword, files, readFile, done) {
56
56
  svg_cleanup.cleanupSVG(svg, options);
57
57
  iconSet.fromSVG(keyword, svg);
58
58
  } catch (err) {
59
- if (options.ignoreImportErrors !== false) {
60
- throw err;
59
+ const ignore = options.ignoreImportErrors ?? false;
60
+ if (ignore === false || ignore === "warn") {
61
+ let msg = `Failed to import "${keyword}"`;
62
+ if (err instanceof Error) {
63
+ msg += `: ${err.message}`;
64
+ }
65
+ if (ignore === false) {
66
+ throw new Error(msg);
67
+ } else {
68
+ console.warn(msg);
69
+ }
61
70
  }
62
71
  }
63
72
  next();
@@ -37,7 +37,7 @@ interface ImportDirectoryOptions<K> extends CleanupSVGOptions {
37
37
  prefix?: string;
38
38
  includeSubDirs?: boolean;
39
39
  keyword?: K;
40
- ignoreImportErrors?: boolean;
40
+ ignoreImportErrors?: boolean | 'warn';
41
41
  }
42
42
  /**
43
43
  * Import all icons from directory
@@ -54,8 +54,17 @@ function importDir(iconSet, options, getKeyword, files, readFile, done) {
54
54
  cleanupSVG(svg, options);
55
55
  iconSet.fromSVG(keyword, svg);
56
56
  } catch (err) {
57
- if (options.ignoreImportErrors !== false) {
58
- throw err;
57
+ const ignore = options.ignoreImportErrors ?? false;
58
+ if (ignore === false || ignore === "warn") {
59
+ let msg = `Failed to import "${keyword}"`;
60
+ if (err instanceof Error) {
61
+ msg += `: ${err.message}`;
62
+ }
63
+ if (ignore === false) {
64
+ throw new Error(msg);
65
+ } else {
66
+ console.warn(msg);
67
+ }
59
68
  }
60
69
  }
61
70
  next();
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
5
5
  "author": "Vjacheslav Trushkin",
6
- "version": "3.0.4",
6
+ "version": "3.0.5",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/iconify/tools/issues",
9
9
  "homepage": "https://github.com/iconify/tools",