@iconify/tools 1.3.17 → 2.0.0-dev.2

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.
Files changed (147) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintignore +2 -0
  3. package/lib/colors/attribs.d.ts +16 -0
  4. package/lib/colors/attribs.js +26 -0
  5. package/lib/colors/attribs.mjs +28 -0
  6. package/lib/colors/parse.d.ts +37 -0
  7. package/lib/colors/parse.js +261 -0
  8. package/lib/colors/parse.mjs +212 -0
  9. package/lib/css/parse.d.ts +4 -0
  10. package/lib/css/parse.js +23 -0
  11. package/lib/css/parse.mjs +20 -0
  12. package/lib/css/parser/error.d.ts +11 -0
  13. package/lib/css/parser/error.js +27 -0
  14. package/lib/css/parser/error.mjs +23 -0
  15. package/lib/css/parser/export.d.ts +5 -0
  16. package/lib/css/parser/export.js +69 -0
  17. package/lib/css/parser/export.mjs +46 -0
  18. package/lib/css/parser/strings.d.ts +13 -0
  19. package/lib/css/parser/strings.js +93 -0
  20. package/lib/css/parser/strings.mjs +74 -0
  21. package/lib/css/parser/text.d.ts +17 -0
  22. package/lib/css/parser/text.js +174 -0
  23. package/lib/css/parser/text.mjs +133 -0
  24. package/lib/css/parser/tokens.d.ts +6 -0
  25. package/lib/css/parser/tokens.js +200 -0
  26. package/lib/css/parser/tokens.mjs +186 -0
  27. package/lib/css/parser/tree.d.ts +5 -0
  28. package/lib/css/parser/tree.js +44 -0
  29. package/lib/css/parser/tree.mjs +40 -0
  30. package/lib/css/parser/types.d.ts +51 -0
  31. package/lib/css/parser/types.js +2 -0
  32. package/lib/css/parser/types.mjs +0 -0
  33. package/lib/icon-set/index.d.ts +134 -0
  34. package/lib/icon-set/index.js +776 -0
  35. package/lib/icon-set/index.mjs +617 -0
  36. package/lib/icon-set/match.d.ts +6 -0
  37. package/lib/icon-set/match.js +66 -0
  38. package/lib/icon-set/match.mjs +55 -0
  39. package/lib/icon-set/merge.d.ts +5 -0
  40. package/lib/icon-set/merge.js +91 -0
  41. package/lib/icon-set/merge.mjs +75 -0
  42. package/lib/icon-set/props.d.ts +10 -0
  43. package/lib/icon-set/props.js +33 -0
  44. package/lib/icon-set/props.mjs +25 -0
  45. package/lib/icon-set/types.d.ts +68 -0
  46. package/lib/icon-set/types.js +2 -0
  47. package/lib/icon-set/types.mjs +0 -0
  48. package/lib/import/directory.d.ts +35 -0
  49. package/lib/import/directory.js +59 -0
  50. package/lib/import/directory.mjs +47 -0
  51. package/lib/misc/keyword.d.ts +4 -0
  52. package/lib/misc/keyword.js +31 -0
  53. package/lib/misc/keyword.mjs +17 -0
  54. package/lib/misc/scan.d.ts +24 -0
  55. package/lib/misc/scan.js +48 -0
  56. package/lib/misc/scan.mjs +43 -0
  57. package/lib/optimise/flags.d.ts +5 -0
  58. package/lib/optimise/flags.js +303 -0
  59. package/lib/optimise/flags.mjs +241 -0
  60. package/lib/optimise/scale.d.ts +5 -0
  61. package/lib/optimise/scale.js +42 -0
  62. package/lib/optimise/scale.mjs +22 -0
  63. package/lib/optimise/svgo.d.ts +27 -0
  64. package/lib/optimise/svgo.js +88 -0
  65. package/lib/optimise/svgo.mjs +75 -0
  66. package/lib/svg/cleanup/attribs.d.ts +5 -0
  67. package/lib/svg/cleanup/attribs.js +43 -0
  68. package/lib/svg/cleanup/attribs.mjs +36 -0
  69. package/lib/svg/cleanup/bad-tags.d.ts +5 -0
  70. package/lib/svg/cleanup/bad-tags.js +69 -0
  71. package/lib/svg/cleanup/bad-tags.mjs +68 -0
  72. package/lib/svg/cleanup/inline-style.d.ts +5 -0
  73. package/lib/svg/cleanup/inline-style.js +77 -0
  74. package/lib/svg/cleanup/inline-style.mjs +65 -0
  75. package/lib/svg/cleanup/root-svg.d.ts +5 -0
  76. package/lib/svg/cleanup/root-svg.js +106 -0
  77. package/lib/svg/cleanup/root-svg.mjs +88 -0
  78. package/lib/svg/cleanup/svgo-style.d.ts +5 -0
  79. package/lib/svg/cleanup/svgo-style.js +35 -0
  80. package/lib/svg/cleanup/svgo-style.mjs +29 -0
  81. package/lib/svg/cleanup.d.ts +5 -0
  82. package/lib/svg/cleanup.js +24 -0
  83. package/lib/svg/cleanup.mjs +16 -0
  84. package/lib/svg/data/attributes.d.ts +71 -0
  85. package/lib/svg/data/attributes.js +403 -0
  86. package/lib/svg/data/attributes.mjs +352 -0
  87. package/lib/svg/data/tags.d.ts +89 -0
  88. package/lib/svg/data/tags.js +185 -0
  89. package/lib/svg/data/tags.mjs +136 -0
  90. package/lib/svg/index.d.ts +33 -0
  91. package/lib/svg/index.js +122 -0
  92. package/lib/svg/index.mjs +85 -0
  93. package/lib/svg/parse-style.d.ts +40 -0
  94. package/lib/svg/parse-style.js +131 -0
  95. package/lib/svg/parse-style.mjs +109 -0
  96. package/lib/svg/parse.d.ts +30 -0
  97. package/lib/svg/parse.js +49 -0
  98. package/lib/svg/parse.mjs +40 -0
  99. package/package.json +167 -13
  100. package/README.md +0 -576
  101. package/license.txt +0 -21
  102. package/sample/parse.js +0 -74
  103. package/sample/source/icon-close.svg +0 -15
  104. package/sample/source/icon-confirm.svg +0 -14
  105. package/sample/source/icon-search.svg +0 -16
  106. package/src/collection.js +0 -641
  107. package/src/colors/change_palette.js +0 -227
  108. package/src/colors/get_palette.js +0 -143
  109. package/src/colors/opacify.js +0 -195
  110. package/src/export/component.js +0 -482
  111. package/src/export/dir.js +0 -109
  112. package/src/export/json.js +0 -329
  113. package/src/export/phantomjs.js +0 -76
  114. package/src/export/phantomjs_script.js +0 -125
  115. package/src/export/png.js +0 -193
  116. package/src/export/svg.js +0 -55
  117. package/src/export/templates/component.md +0 -79
  118. package/src/export/templates/info.md +0 -3
  119. package/src/export/templates/sample-react-1.md +0 -21
  120. package/src/export/templates/sample-react-2.md +0 -15
  121. package/src/export/templates/sample-react.md +0 -11
  122. package/src/export/templates/sample-svelte.md +0 -11
  123. package/src/export/templates/sample-svelte1.md +0 -22
  124. package/src/export/templates/sample-svelte2.md +0 -13
  125. package/src/export/templates/sample-vue-0.md +0 -30
  126. package/src/export/templates/sample-vue-1.md +0 -25
  127. package/src/export/templates/sample-vue-2.md +0 -27
  128. package/src/export/templates/sample-vue.md +0 -28
  129. package/src/helpers.js +0 -43
  130. package/src/import/dir.js +0 -234
  131. package/src/import/font.js +0 -402
  132. package/src/import/json.js +0 -200
  133. package/src/import/svg.js +0 -60
  134. package/src/import/web_icons.js +0 -248
  135. package/src/modules.js +0 -50
  136. package/src/optimize/crop.js +0 -554
  137. package/src/optimize/crop_script.js +0 -525
  138. package/src/optimize/flags.js +0 -430
  139. package/src/optimize/scale.js +0 -72
  140. package/src/optimize/svgo.js +0 -161
  141. package/src/optimize/tags.js +0 -522
  142. package/src/shapes/convert.js +0 -264
  143. package/src/shapes/index.js +0 -135
  144. package/src/shapes/length.js +0 -707
  145. package/src/shapes/length_script.js +0 -105
  146. package/src/shapes/options.js +0 -60
  147. package/src/svg.js +0 -162
package/src/export/svg.js DELETED
@@ -1,55 +0,0 @@
1
- /**
2
- * This file is part of the @iconify/tools package.
3
- *
4
- * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- 'use strict';
11
-
12
- const fs = require('fs');
13
- const path = require('path');
14
- const helpers = require('../helpers');
15
-
16
- const defaults = {
17
- reject: true,
18
- };
19
-
20
- /**
21
- * Export to .svg file
22
- *
23
- * @returns {Promise}
24
- */
25
- module.exports = (svg, target, options) => {
26
- options = options === void 0 ? Object.create(null) : options;
27
- Object.keys(defaults).forEach(key => {
28
- if (options[key] === void 0) {
29
- options[key] = defaults[key];
30
- }
31
- });
32
-
33
- return new Promise((fulfill, reject) => {
34
- fs.writeFile(target, svg.toString(), 'utf8', err => {
35
- if (err) {
36
- // Attempt to create directories
37
- helpers.mkdir(path.dirname(target));
38
-
39
- fs.writeFile(target, svg.toString(), 'utf8', err => {
40
- if (err) {
41
- if (options.reject) {
42
- reject(err);
43
- } else {
44
- fulfill(null);
45
- }
46
- } else {
47
- fulfill(svg);
48
- }
49
- });
50
- } else {
51
- fulfill(svg);
52
- }
53
- });
54
- });
55
- };
@@ -1,79 +0,0 @@
1
- # iconSetName
2
-
3
- This package includes individual files for each icon, ready to be imported into a project.
4
-
5
- Each icon is in its own file, so you can bundle several icons from different icon sets without bundling entire icon sets.
6
-
7
- ## Installation
8
-
9
- If you are using NPM:
10
-
11
- ```bash
12
- npm install packageName --save-dev
13
- ```
14
-
15
- If you are using Yarn:
16
-
17
- ```bash
18
- yarn add --dev packageName
19
- ```
20
-
21
- ## Usage with React
22
-
23
- First you need to install [Iconify for React](https://github.com/iconify/iconify/packages/react).
24
-
25
- If you are using NPM:
26
-
27
- ```bash
28
- npm install --save-dev @iconify/react
29
- ```
30
-
31
- If you are using Yarn:
32
-
33
- ```bash
34
- yarn add --dev @iconify/react
35
- ```
36
-
37
- `samples.react`
38
-
39
- See https://github.com/iconify/iconify/packages/react for details.
40
-
41
- ## Usage with Vue
42
-
43
- First you need to install [Iconify for Vue](https://github.com/iconify/iconify/packages/vue).
44
-
45
- If you are using NPM:
46
-
47
- ```bash
48
- npm install --save-dev @iconify/vue
49
- ```
50
-
51
- If you are using Yarn:
52
-
53
- ```bash
54
- yarn add --dev @iconify/vue
55
- ```
56
-
57
- `samples.vue`
58
-
59
- See https://github.com/iconify/iconify/packages/vue for details.
60
-
61
- ## Usage with Svelte
62
-
63
- First you need to install [Iconify for Svelte](https://github.com/iconify/iconify/packages/svelte).
64
-
65
- If you are using NPM:
66
-
67
- ```bash
68
- npm install --save-dev @iconify/svelte
69
- ```
70
-
71
- If you are using Yarn:
72
-
73
- ```bash
74
- yarn add --dev @iconify/svelte
75
- ```
76
-
77
- `samples.svelte`
78
-
79
- See https://github.com/iconify/iconify/packages/svelte for details.
@@ -1,3 +0,0 @@
1
- ## About iconSetName
2
-
3
- iconSetInfo
@@ -1,21 +0,0 @@
1
- ### Example using icon 'sampleFilename' with React
2
-
3
- This example is using string syntax that is available since Iconify for React 2.0
4
-
5
- This example will not work with Iconify for React 1.x
6
-
7
- ```jsx
8
- import React from 'react';
9
- import { Icon, addIcon } from '@iconify/react';
10
- import sampleIconName from 'packageName/sampleFilename';
11
-
12
- addIcon('sampleIconShortName', sampleIconName);
13
-
14
- export function MyComponent() {
15
- return (
16
- <div>
17
- <Icon icon="sampleIconShortName" />
18
- </div>
19
- );
20
- }
21
- ```
@@ -1,15 +0,0 @@
1
- ### Example using icon 'sampleFilename' with React
2
-
3
- ```jsx
4
- import React from 'react';
5
- import { InlineIcon } from '@iconify/react';
6
- import sampleIconName from 'packageName/sampleFilename';
7
-
8
- export function MyComponent() {
9
- return (
10
- <p>
11
- <InlineIcon icon={sampleIconName} /> Sample text with an icon.
12
- </p>
13
- );
14
- }
15
- ```
@@ -1,11 +0,0 @@
1
- ### Example using icon 'sampleFilename' with React
2
-
3
- ```js
4
- import { Icon, InlineIcon } from '@iconify/react';
5
- import sampleIconName from 'packageName/sampleFilename';
6
- ```
7
-
8
- ```jsx
9
- <Icon icon={sampleIconName} />
10
- <p>This is some text with icon adjusted for baseline: <InlineIcon icon={sampleIconName} /></p>
11
- ```
@@ -1,11 +0,0 @@
1
- ### Example using icon 'sampleFilename' with Svelte
2
-
3
- ```svelte
4
- <script>
5
- // npm install --save-dev @iconify/svelte packageName
6
- import IconifyIcon from '@iconify/svelte';
7
- import sampleIconName from 'packageName/sampleFilename';
8
- </script>
9
-
10
- <IconifyIcon icon={sampleIconName} />
11
- ```
@@ -1,22 +0,0 @@
1
- ### Example using icon 'sampleFilename' with Svelte
2
-
3
- This example shows how to use stylesheet with Svelte component.
4
-
5
- ```svelte
6
- <script>
7
- // npm install --save-dev @iconify/svelte packageName
8
- import IconifyIcon from '@iconify/svelte';
9
- import sampleIconName from 'packageName/sampleFilename';
10
- </script>
11
- <style>
12
- /*
13
- Cannot target component in CSS, target SVG
14
- instead using Svelte's :global() function
15
- */
16
- div :global(svg) {
17
- vertical-align: -0.125em;
18
- }
19
- </style>
20
-
21
- <IconifyIcon icon={sampleIconName} />
22
- ```
@@ -1,13 +0,0 @@
1
- ### Example using icon 'sampleFilename' with Svelte
2
-
3
- Most Markdown parsers do not highlight Svelte syntax, so this example splits script and template into 2 sections to highlight syntax.
4
-
5
- ```js
6
- import IconifyIcon from '@iconify/svelte';
7
- import sampleIconName from 'packageName/sampleFilename';
8
- ```
9
-
10
- ```jsx
11
- <IconifyIcon icon={sampleIconName} />
12
- <p>This is some text with icon adjusted for baseline: <IconifyIcon icon={sampleIconName} inline={true} /></p>
13
- ```
@@ -1,30 +0,0 @@
1
- ### Example using icon 'sampleFilename' with Vue
2
-
3
- This example is using object syntax with TypeScript.
4
-
5
- ```vue
6
- <template>
7
- <p>
8
- <iconify-icon :icon="icons.sampleIconShortName" />
9
- </p>
10
- </template>
11
-
12
- <script lang="ts">
13
- import { Component, Prop, Vue } from 'vue-property-decorator';
14
- import IconifyIcon from '@iconify/vue';
15
- import sampleIconName from 'packageName/sampleFilename';
16
-
17
- export default Vue.extend({
18
- components: {
19
- IconifyIcon,
20
- },
21
- data() {
22
- return {
23
- icons: {
24
- sampleIconShortName: sampleIconName,
25
- },
26
- };
27
- },
28
- });
29
- </script>
30
- ```
@@ -1,25 +0,0 @@
1
- ### Example using icon 'sampleFilename' with Vue
2
-
3
- This example is using string syntax.
4
-
5
- ```vue
6
- <template>
7
- <p>
8
- Example of 'sampleFilename' icon:
9
- <iconify-icon icon="sampleIconShortName" :inline="true" />!
10
- </p>
11
- </template>
12
-
13
- <script>
14
- import IconifyIcon from '@iconify/vue';
15
- import sampleIconName from 'packageName/sampleFilename';
16
-
17
- IconifyIcon.addIcon('sampleIconShortName', sampleIconName);
18
-
19
- export default {
20
- components: {
21
- IconifyIcon,
22
- },
23
- };
24
- </script>
25
- ```
@@ -1,27 +0,0 @@
1
- ### Example using icon 'sampleFilename' with Vue
2
-
3
- This example is using object syntax.
4
-
5
- ```vue
6
- <template>
7
- <iconify-icon :icon="icons.sampleIconName" />
8
- </template>
9
-
10
- <script>
11
- import IconifyIcon from '@iconify/vue';
12
- import sampleIconName from 'packageName/sampleFilename';
13
-
14
- export default {
15
- components: {
16
- IconifyIcon,
17
- },
18
- data() {
19
- return {
20
- icons: {
21
- sampleIconName,
22
- },
23
- };
24
- },
25
- };
26
- </script>
27
- ```
@@ -1,28 +0,0 @@
1
- ### Example using icon 'sampleFilename' with Vue
2
-
3
- ```vue
4
- <template>
5
- <p>
6
- <iconify-icon :icon="icons.sampleIconShortName" />
7
- </p>
8
- </template>
9
-
10
- <script lang="ts">
11
- import { Component, Prop, Vue } from 'vue-property-decorator';
12
- import IconifyIcon from '@iconify/vue';
13
- import sampleIconName from 'packageName/sampleFilename';
14
-
15
- export default Vue.extend({
16
- components: {
17
- IconifyIcon,
18
- },
19
- data() {
20
- return {
21
- icons: {
22
- sampleIconShortName: sampleIconName,
23
- },
24
- };
25
- },
26
- });
27
- </script>
28
- ```
package/src/helpers.js DELETED
@@ -1,43 +0,0 @@
1
- /**
2
- * This file is part of the @iconify/tools package.
3
- *
4
- * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- 'use strict';
11
-
12
- const fs = require('fs');
13
-
14
- const functions = {
15
- /**
16
- * Recursively create directory
17
- *
18
- * @param path
19
- */
20
- mkdir: path => {
21
- if (typeof path === 'string' && path === '.') {
22
- return;
23
- }
24
-
25
- let dirs = typeof path === 'string' ? path.split('/') : path,
26
- dir;
27
-
28
- if (dirs.length) {
29
- dir = '';
30
- dirs.forEach(part => {
31
- dir += part;
32
- if (dir.length) {
33
- try {
34
- fs.mkdirSync(dir, 0o755);
35
- } catch (err) {}
36
- }
37
- dir += '/';
38
- });
39
- }
40
- },
41
- };
42
-
43
- module.exports = functions;
package/src/import/dir.js DELETED
@@ -1,234 +0,0 @@
1
- /**
2
- * This file is part of the @iconify/tools package.
3
- *
4
- * (c) Vjacheslav Trushkin <cyberalien@gmail.com>
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
-
10
- 'use strict';
11
-
12
- const fs = require('fs');
13
- const Importer = require('./svg');
14
- const Collection = require('../collection');
15
-
16
- const defaults = {
17
- // Prefix for icons
18
- prefix: null,
19
-
20
- // Check sub-directories
21
- includeSubDirs: true,
22
-
23
- // Treat subdirectory as prefix: "fa-pro/icon.svg" -> prefix = "fa-pro"
24
- directoryAsPrefix: false,
25
-
26
- // If filename includes prefix, such as "fa-pro/fa-pro-home"
27
- // this option will remove duplicate prefix
28
- removePrefix: false,
29
-
30
- // Function to create keyword from filename
31
- keywordCallback: keyword,
32
-
33
- // If false, error will be logged when files with duplicate names are found. See "log" option
34
- ignoreDuplicates: false,
35
-
36
- // Array of files to ignore. Each entry is keyword or full file name
37
- // It could also be function(name) that should return true if file is ignored, false if not
38
- ignoreFiles: false,
39
-
40
- // Options for SVG importer. See "svg.js" in this directory
41
- contentCallback: null, // callback to call to test content
42
- minify: true,
43
- headless: true,
44
-
45
- // Function to log errors. function(message)
46
- log: null,
47
-
48
- // Functions to overwrite for custom importer or scanner (used for unit testing)
49
- scan: scan,
50
- importer: Importer,
51
- };
52
-
53
- /**
54
- * Scan directory. Returns array of svg files
55
- *
56
- * @param {string} dir
57
- * @param {string} prefix
58
- * @param {object} options
59
- * @return {Array}
60
- */
61
- function scan(dir, prefix, options) {
62
- let results = [];
63
-
64
- fs.readdirSync(dir).forEach(file => {
65
- let filename = dir + '/' + file;
66
- if (fs.lstatSync(filename).isDirectory()) {
67
- if (options.includeSubDirs) {
68
- results = results.concat(scan(filename, prefix + file + '/', options));
69
- }
70
- } else {
71
- if (file.toLowerCase().slice(-4) === '.svg') {
72
- results.push(prefix + file);
73
- }
74
- }
75
- });
76
-
77
- return results;
78
- }
79
-
80
- /**
81
- * Get keyword from file
82
- *
83
- * @param {string} key
84
- * @param {string} file
85
- * @param {object} options
86
- * @returns {string}
87
- */
88
- function keyword(key, file, options) {
89
- let result = key
90
- .toLowerCase()
91
- .replace(/_/g, '-')
92
- .replace(/[^a-zA-Z0-9\-_:]/g, '')
93
- .replace(/--*/, '-');
94
- if (
95
- options.prefix &&
96
- options.removePrefix &&
97
- result.slice(0, options.prefix.length + 1) === options.prefix + '-'
98
- ) {
99
- result = result.slice(options.prefix.length + 1);
100
- }
101
- return result;
102
- }
103
-
104
- /**
105
- * Import files from directory
106
- *
107
- * @param {string} source Source directory
108
- * @param {object} [options] List of options
109
- */
110
- module.exports = (source, options) => {
111
- options = options === void 0 ? Object.create(null) : options;
112
- Object.keys(defaults).forEach(key => {
113
- if (options[key] === void 0) {
114
- options[key] = defaults[key];
115
- }
116
- });
117
-
118
- // Check if name (filename or keyword) is ignored
119
- let isIgnored = name => {
120
- if (options.ignoreFiles === false) {
121
- return false;
122
- }
123
- if (typeof options.ignoreFiles === 'function') {
124
- return option.ignoreFiles(name);
125
- }
126
- return (
127
- typeof options.ignoreFiles === 'object' &&
128
- options.ignoreFiles.indexOf(name) !== -1
129
- );
130
- };
131
-
132
- // Return promise
133
- return new Promise((fulfill, reject) => {
134
- let promises = [],
135
- keywords = [],
136
- filenames = [],
137
- collection = new Collection(options.prefix);
138
-
139
- // Remove trailing slash and find all files
140
- if (source.slice(-1) === '/') {
141
- source = source.slice(0, source.length - 1);
142
- }
143
- let files = options.scan(source, '', options);
144
-
145
- // Get promise for each file
146
- files.forEach(file => {
147
- // Check if keyword is ignored
148
- if (isIgnored(file)) {
149
- return;
150
- }
151
-
152
- // Get keyword
153
- let fileSplit = file.split('/'),
154
- keyword = fileSplit.pop().split('.')[0];
155
-
156
- if (options.directoryAsPrefix) {
157
- let dir;
158
- if (fileSplit.length) {
159
- dir = fileSplit.pop();
160
- } else {
161
- dir = source.split('/').pop();
162
- }
163
- if (
164
- options.removeDirectoryPrefix &&
165
- keyword.slice(0, dir.length + 1) === dir + '-'
166
- ) {
167
- keyword = keyword.slice(dir.length + 1);
168
- }
169
- keyword = dir + ':' + keyword;
170
- }
171
-
172
- keyword = options.keywordCallback(keyword, file, options);
173
-
174
- if (typeof keyword !== 'string') {
175
- return;
176
- }
177
-
178
- if (!keyword.length) {
179
- if (options.log) {
180
- options.log('Cannot extract keyword from file: ' + file);
181
- }
182
- return;
183
- }
184
-
185
- if (keywords.indexOf(keyword) !== -1) {
186
- if (options.log && !options.ignoreDuplicates) {
187
- options.log('Duplicate keyword: ' + keyword);
188
- }
189
- return;
190
- }
191
-
192
- // Check if keyword is ignored
193
- if (isIgnored(keyword)) {
194
- return;
195
- }
196
-
197
- // Load file
198
- filenames.push(file);
199
- keywords.push(keyword);
200
- promises.push(
201
- options.importer(source + '/' + file, {
202
- reject: false,
203
- contentCallback: options.contentCallback,
204
- headless: options.headless,
205
- minify: options.minify,
206
- })
207
- );
208
- });
209
-
210
- // Load all files
211
- Promise.all(promises)
212
- .then(results => {
213
- keywords.forEach((keyword, index) => {
214
- if (results[index] === null) {
215
- if (options.log) {
216
- options.log('Failed to load: ' + filenames[index]);
217
- }
218
- return;
219
- }
220
- collection.add(keyword, results[index]);
221
- });
222
-
223
- // Detect prefix
224
- if (options.prefix === null) {
225
- collection.findCommonPrefix(true);
226
- }
227
-
228
- fulfill(collection);
229
- })
230
- .catch(err => {
231
- reject(err);
232
- });
233
- });
234
- };