js-build-tools 3.0.0 → 3.0.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 (64) hide show
  1. package/dist/build.js +59 -59
  2. package/dist/bundle.js +12 -12
  3. package/dist/bundleLint.js +17 -17
  4. package/dist/bundleMinify.js +8 -8
  5. package/dist/copyFonts.js +8 -8
  6. package/dist/default.js +15 -15
  7. package/dist/distLint.js +17 -17
  8. package/dist/distMinify.js +8 -8
  9. package/dist/partials/addToReadme.js +13 -13
  10. package/dist/partials/beginWatcher.js +9 -9
  11. package/dist/partials/distFor.js +16 -16
  12. package/dist/partials/distForSrc.js +9 -9
  13. package/dist/partials/distSeries.js +19 -19
  14. package/dist/partials/imagesFor.js +27 -27
  15. package/dist/partials/readmeTemplate.js +11 -11
  16. package/dist/partials/runOnChange.js +27 -27
  17. package/dist/partials/sassFor.js +20 -20
  18. package/dist/partials/tsFor.js +20 -20
  19. package/dist/partials.js +34 -34
  20. package/dist/test-helpers/setUp.js +51 -51
  21. package/dist/testFull.js +17 -17
  22. package/dist/testHelpers.js +8 -8
  23. package/dist/testQuick.js +19 -19
  24. package/dist/utilities/dotGet.js +42 -42
  25. package/dist/utilities/dotNotate.js +50 -50
  26. package/dist/utilities/dotSet.js +36 -36
  27. package/dist/utilities/isObject.js +4 -4
  28. package/dist/utilities/strAfter.js +14 -0
  29. package/dist/utilities/strBefore.js +14 -0
  30. package/dist/watchTest.js +13 -13
  31. package/functions/utilities/dotGet.js +2 -2
  32. package/functions/utilities/dotSet.js +2 -2
  33. package/functions/utilities/strAfter.js +13 -0
  34. package/functions/utilities/strBefore.js +13 -0
  35. package/package.json +4 -4
  36. package/vendor/array-union/index.js +30 -30
  37. package/vendor/easy-transform-stream/index.js +54 -58
  38. package/vendor/globby/gitignore.js +96 -100
  39. package/vendor/globby/index.js +191 -195
  40. package/vendor/globby/stream-utils.js +57 -57
  41. package/vendor/globby/to-path.js +19 -19
  42. package/vendor/gulp-imagemin/index.js +5 -9
  43. package/vendor/gulp-plugin-extras/index.js +42 -46
  44. package/vendor/gulp-plugin-extras/plugin-error.js +144 -144
  45. package/vendor/ignore/index.js +467 -467
  46. package/vendor/imagemin/index.js +90 -94
  47. package/vendor/imagemin-gifsicle/index.js +33 -37
  48. package/vendor/imagemin-mozjpeg/index.js +100 -104
  49. package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +2 -6
  50. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +2 -2
  51. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +2 -6
  52. package/vendor/imagemin-optipng/index.js +43 -43
  53. package/vendor/imagemin-svgo/index.js +26 -26
  54. package/vendor/is-jpg/index.js +11 -11
  55. package/vendor/junk/index.js +48 -48
  56. package/vendor/mozjpeg/index.js +8 -8
  57. package/vendor/mozjpeg/lib/index.js +17 -17
  58. package/vendor/mozjpeg/package.json +49 -50
  59. package/vendor/mozjpeg/vendor/cjpeg +0 -0
  60. package/vendor/mozjpeg/vendor/source/mozjpeg.tar.gz +0 -0
  61. package/vendor/p-pipe/index.js +22 -26
  62. package/vendor/plur/index.js +31 -31
  63. package/vendor/pretty-bytes/index.js +70 -70
  64. package/vendor/slash/index.js +11 -11
@@ -1,58 +1,58 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.UniqueStream = exports.FilterStream = void 0;
7
- require("core-js/modules/esnext.set.add-all.js");
8
- require("core-js/modules/esnext.set.delete-all.js");
9
- require("core-js/modules/esnext.set.difference.js");
10
- require("core-js/modules/esnext.set.every.js");
11
- require("core-js/modules/esnext.set.filter.js");
12
- require("core-js/modules/esnext.set.find.js");
13
- require("core-js/modules/esnext.set.intersection.js");
14
- require("core-js/modules/esnext.set.is-disjoint-from.js");
15
- require("core-js/modules/esnext.set.is-subset-of.js");
16
- require("core-js/modules/esnext.set.is-superset-of.js");
17
- require("core-js/modules/esnext.set.join.js");
18
- require("core-js/modules/esnext.set.map.js");
19
- require("core-js/modules/esnext.set.reduce.js");
20
- require("core-js/modules/esnext.set.some.js");
21
- require("core-js/modules/esnext.set.symmetric-difference.js");
22
- require("core-js/modules/esnext.set.union.js");
23
- require("core-js/modules/web.dom-collections.iterator.js");
24
- var _nodeStream = require("node:stream");
25
- class ObjectTransform extends _nodeStream.Transform {
26
- constructor() {
27
- super({
28
- objectMode: true
29
- });
30
- }
31
- }
32
- class FilterStream extends ObjectTransform {
33
- constructor(filter) {
34
- super();
35
- this._filter = filter;
36
- }
37
- _transform(data, encoding, callback) {
38
- if (this._filter(data)) {
39
- this.push(data);
40
- }
41
- callback();
42
- }
43
- }
44
- exports.FilterStream = FilterStream;
45
- class UniqueStream extends ObjectTransform {
46
- constructor() {
47
- super();
48
- this._pushed = new Set();
49
- }
50
- _transform(data, encoding, callback) {
51
- if (!this._pushed.has(data)) {
52
- this.push(data);
53
- this._pushed.add(data);
54
- }
55
- callback();
56
- }
57
- }
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UniqueStream = exports.FilterStream = void 0;
7
+ require("core-js/modules/esnext.set.add-all.js");
8
+ require("core-js/modules/esnext.set.delete-all.js");
9
+ require("core-js/modules/esnext.set.difference.js");
10
+ require("core-js/modules/esnext.set.every.js");
11
+ require("core-js/modules/esnext.set.filter.js");
12
+ require("core-js/modules/esnext.set.find.js");
13
+ require("core-js/modules/esnext.set.intersection.js");
14
+ require("core-js/modules/esnext.set.is-disjoint-from.js");
15
+ require("core-js/modules/esnext.set.is-subset-of.js");
16
+ require("core-js/modules/esnext.set.is-superset-of.js");
17
+ require("core-js/modules/esnext.set.join.js");
18
+ require("core-js/modules/esnext.set.map.js");
19
+ require("core-js/modules/esnext.set.reduce.js");
20
+ require("core-js/modules/esnext.set.some.js");
21
+ require("core-js/modules/esnext.set.symmetric-difference.js");
22
+ require("core-js/modules/esnext.set.union.js");
23
+ require("core-js/modules/web.dom-collections.iterator.js");
24
+ var _nodeStream = require("node:stream");
25
+ class ObjectTransform extends _nodeStream.Transform {
26
+ constructor() {
27
+ super({
28
+ objectMode: true
29
+ });
30
+ }
31
+ }
32
+ class FilterStream extends ObjectTransform {
33
+ constructor(filter) {
34
+ super();
35
+ this._filter = filter;
36
+ }
37
+ _transform(data, encoding, callback) {
38
+ if (this._filter(data)) {
39
+ this.push(data);
40
+ }
41
+ callback();
42
+ }
43
+ }
44
+ exports.FilterStream = FilterStream;
45
+ class UniqueStream extends ObjectTransform {
46
+ constructor() {
47
+ super();
48
+ this._pushed = new Set();
49
+ }
50
+ _transform(data, encoding, callback) {
51
+ if (!this._pushed.has(data)) {
52
+ this.push(data);
53
+ this._pushed.add(data);
54
+ }
55
+ callback();
56
+ }
57
+ }
58
58
  exports.UniqueStream = UniqueStream;
@@ -1,20 +1,20 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- require("core-js/modules/web.dom-collections.iterator.js");
8
- require("core-js/modules/web.url.js");
9
- require("core-js/modules/web.url-search-params.js");
10
- var _nodeUrl = require("node:url");
11
- const toPath = urlOrPath => {
12
- if (!urlOrPath) {
13
- return urlOrPath;
14
- }
15
- if (urlOrPath instanceof URL) {
16
- urlOrPath = urlOrPath.href;
17
- }
18
- return urlOrPath.startsWith('file://') ? (0, _nodeUrl.fileURLToPath)(urlOrPath) : urlOrPath;
19
- };
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ require("core-js/modules/web.dom-collections.iterator.js");
8
+ require("core-js/modules/web.url.js");
9
+ require("core-js/modules/web.url-search-params.js");
10
+ var _nodeUrl = require("node:url");
11
+ const toPath = urlOrPath => {
12
+ if (!urlOrPath) {
13
+ return urlOrPath;
14
+ }
15
+ if (urlOrPath instanceof URL) {
16
+ urlOrPath = urlOrPath.href;
17
+ }
18
+ return urlOrPath.startsWith('file://') ? (0, _nodeUrl.fileURLToPath)(urlOrPath) : urlOrPath;
19
+ };
20
20
  var _default = exports.default = toPath;
@@ -1,5 +1,4 @@
1
- async function exportGulpImagemin () {
2
- "use strict";
1
+ "use strict";
3
2
 
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
@@ -119,10 +118,7 @@ function gulpImagemin(plugins, options) {
119
118
  }
120
119
  });
121
120
  }
122
- const gifsicle = exports.gifsicle = await exposePlugin('gifsicle');
123
- const mozjpeg = exports.mozjpeg = await exposePlugin('mozjpeg');
124
- const optipng = exports.optipng = await exposePlugin('optipng');
125
- const svgo = exports.svgo = await exposePlugin('svgo');
126
- }
127
-
128
- exportGulpImagemin()
121
+ const gifsicle = exports.gifsicle = exposePlugin('gifsicle');
122
+ const mozjpeg = exports.mozjpeg = exposePlugin('mozjpeg');
123
+ const optipng = exports.optipng = exposePlugin('optipng');
124
+ const svgo = exports.svgo = exposePlugin('svgo');
@@ -1,46 +1,42 @@
1
- async function exportGulpPluginExtras () {
2
- "use strict";
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.gulpPlugin = gulpPlugin;
8
- require("core-js/modules/web.dom-collections.iterator.js");
9
- var _index = _interopRequireDefault(require("../easy-transform-stream/index.js"));
10
- var _pluginError = _interopRequireDefault(require("./plugin-error.js"));
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- function gulpPlugin(name, onFile) {
13
- let {
14
- onFinish,
15
- supportsDirectories
16
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
17
- return (0, _index.default)({
18
- objectMode: true
19
- }, async file => {
20
- if (file.isNull() && !(supportsDirectories && file.isDirectory())) {
21
- return file;
22
- }
23
- if (file.isStream()) {
24
- throw new _pluginError.default(name, 'Streaming not supported');
25
- }
26
- try {
27
- return await onFile(file);
28
- } catch (error) {
29
- throw new _pluginError.default(name, error, {
30
- fileName: file.path,
31
- showStack: true
32
- });
33
- }
34
- }, onFinish && async function* (stream) {
35
- try {
36
- yield* onFinish(stream);
37
- } catch (error) {
38
- throw new _pluginError.default(name, error, {
39
- showStack: true
40
- });
41
- }
42
- });
43
- }
44
- }
45
-
46
- exportGulpPluginExtras()
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.gulpPlugin = gulpPlugin;
7
+ require("core-js/modules/web.dom-collections.iterator.js");
8
+ var _index = _interopRequireDefault(require("../easy-transform-stream/index.js"));
9
+ var _pluginError = _interopRequireDefault(require("./plugin-error.js"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ function gulpPlugin(name, onFile) {
12
+ let {
13
+ onFinish,
14
+ supportsDirectories
15
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
16
+ return (0, _index.default)({
17
+ objectMode: true
18
+ }, async file => {
19
+ if (file.isNull() && !(supportsDirectories && file.isDirectory())) {
20
+ return file;
21
+ }
22
+ if (file.isStream()) {
23
+ throw new _pluginError.default(name, 'Streaming not supported');
24
+ }
25
+ try {
26
+ return await onFile(file);
27
+ } catch (error) {
28
+ throw new _pluginError.default(name, error, {
29
+ fileName: file.path,
30
+ showStack: true
31
+ });
32
+ }
33
+ }, onFinish && async function* (stream) {
34
+ try {
35
+ yield* onFinish(stream);
36
+ } catch (error) {
37
+ throw new _pluginError.default(name, error, {
38
+ showStack: true
39
+ });
40
+ }
41
+ });
42
+ }
@@ -1,145 +1,145 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- require("core-js/modules/esnext.async-iterator.filter.js");
8
- require("core-js/modules/esnext.async-iterator.map.js");
9
- require("core-js/modules/esnext.iterator.constructor.js");
10
- require("core-js/modules/esnext.iterator.filter.js");
11
- require("core-js/modules/esnext.iterator.map.js");
12
- require("core-js/modules/esnext.set.add-all.js");
13
- require("core-js/modules/esnext.set.delete-all.js");
14
- require("core-js/modules/esnext.set.difference.js");
15
- require("core-js/modules/esnext.set.every.js");
16
- require("core-js/modules/esnext.set.filter.js");
17
- require("core-js/modules/esnext.set.find.js");
18
- require("core-js/modules/esnext.set.intersection.js");
19
- require("core-js/modules/esnext.set.is-disjoint-from.js");
20
- require("core-js/modules/esnext.set.is-subset-of.js");
21
- require("core-js/modules/esnext.set.is-superset-of.js");
22
- require("core-js/modules/esnext.set.join.js");
23
- require("core-js/modules/esnext.set.map.js");
24
- require("core-js/modules/esnext.set.reduce.js");
25
- require("core-js/modules/esnext.set.some.js");
26
- require("core-js/modules/esnext.set.symmetric-difference.js");
27
- require("core-js/modules/esnext.set.union.js");
28
- require("core-js/modules/web.dom-collections.iterator.js");
29
- var _index = _interopRequireDefault(require("./node_modules/chalk/source/index.js"));
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
- /*
32
- The MIT License (MIT)
33
-
34
- Copyright (c) 2015, 2017-2018, 2022 Blaine Bublitz <blaine.bublitz@gmail.com> and Eric Schoffstall <yo@contra.io>
35
-
36
- Permission is hereby granted, free of charge, to any person obtaining a copy
37
- of this software and associated documentation files (the "Software"), to deal
38
- in the Software without restriction, including without limitation the rights
39
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40
- copies of the Software, and to permit persons to whom the Software is
41
- furnished to do so, subject to the following conditions:
42
-
43
- The above copyright notice and this permission notice shall be included in all
44
- copies or substantial portions of the Software.
45
-
46
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52
- SOFTWARE.
53
- */
54
-
55
- // Adapted from https://github.com/gulpjs/plugin-error 2.0.1
56
-
57
- const nonEnum = ['message', 'name', 'stack'];
58
- const ignored = new Set([...nonEnum, '__safety', '_stack', 'plugin', 'showProperties', 'showStack', 'domain', 'domainEmitter', 'domainThrown']);
59
- const props = ['fileName', 'lineNumber', 'message', 'name', 'plugin', 'showProperties', 'showStack', 'stack'];
60
- class PluginError extends Error {
61
- constructor(plugin, message, options) {
62
- super();
63
- const options_ = setDefaults(plugin, message, options);
64
- Object.assign(this, options_);
65
- if (typeof options_.error === 'object') {
66
- this.message = options_.error.message;
67
- this.stack = options_.error.stack;
68
- this.cause = options_.error.cause;
69
- Object.assign(this, options_.error);
70
- }
71
- for (const prop of props) {
72
- if (prop in options_) {
73
- this[prop] = options_[prop];
74
- }
75
- }
76
- if (!this.stack) {
77
- const safety = {
78
- toString: this._messageWithDetails.bind(this) + '\nStack:'
79
- };
80
- Error.captureStackTrace(safety, this.constructor);
81
- this.__safety = safety;
82
- }
83
- if (!this.plugin) {
84
- throw new Error('Missing plugin name');
85
- }
86
- if (!this.message) {
87
- throw new Error('Missing error message');
88
- }
89
- if (message instanceof Error && options_.error.isPresentable) {
90
- this.showStack = false;
91
- this.showProperties = false;
92
- }
93
- }
94
- _messageWithDetails() {
95
- let message_ = "Message:\n ".concat(this.message);
96
- const details = this._messageDetails();
97
- if (details) {
98
- message_ += "\n".concat(details);
99
- }
100
- return message_;
101
- }
102
- _messageDetails() {
103
- if (!this.showProperties) {
104
- return '';
105
- }
106
- const relevantProps = Object.keys(this).filter(key => !ignored.has(key));
107
- return relevantProps.length > 0 ? "Details:\n".concat(relevantProps.map(prop => " ".concat(prop, ": ").concat(this[prop])).join('\n')) : '';
108
- }
109
- toString() {
110
- const message_ = this.showStack ? this.__safety ? this.__safety.stack : this.stack : this._messageWithDetails();
111
- return formatMessage(message_, this);
112
- }
113
- }
114
- exports.default = PluginError;
115
- function formatMessage(message, thisArg) {
116
- return "".concat(_index.default.red(thisArg.name), " in plugin \"").concat(_index.default.cyan(thisArg.plugin), "\"\n").concat(message);
117
- }
118
- function setDefaults(plugin, message, options) {
119
- if (typeof plugin === 'object') {
120
- return {
121
- ...plugin
122
- };
123
- }
124
- if (message instanceof Error) {
125
- options = {
126
- ...options,
127
- error: message
128
- };
129
- } else if (typeof message === 'object') {
130
- options = {
131
- ...message
132
- };
133
- } else {
134
- options = {
135
- ...options,
136
- message
137
- };
138
- }
139
- options.plugin = plugin;
140
- return {
141
- showStack: false,
142
- showProperties: true,
143
- ...options
144
- };
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ require("core-js/modules/esnext.async-iterator.filter.js");
8
+ require("core-js/modules/esnext.async-iterator.map.js");
9
+ require("core-js/modules/esnext.iterator.constructor.js");
10
+ require("core-js/modules/esnext.iterator.filter.js");
11
+ require("core-js/modules/esnext.iterator.map.js");
12
+ require("core-js/modules/esnext.set.add-all.js");
13
+ require("core-js/modules/esnext.set.delete-all.js");
14
+ require("core-js/modules/esnext.set.difference.js");
15
+ require("core-js/modules/esnext.set.every.js");
16
+ require("core-js/modules/esnext.set.filter.js");
17
+ require("core-js/modules/esnext.set.find.js");
18
+ require("core-js/modules/esnext.set.intersection.js");
19
+ require("core-js/modules/esnext.set.is-disjoint-from.js");
20
+ require("core-js/modules/esnext.set.is-subset-of.js");
21
+ require("core-js/modules/esnext.set.is-superset-of.js");
22
+ require("core-js/modules/esnext.set.join.js");
23
+ require("core-js/modules/esnext.set.map.js");
24
+ require("core-js/modules/esnext.set.reduce.js");
25
+ require("core-js/modules/esnext.set.some.js");
26
+ require("core-js/modules/esnext.set.symmetric-difference.js");
27
+ require("core-js/modules/esnext.set.union.js");
28
+ require("core-js/modules/web.dom-collections.iterator.js");
29
+ var _index = _interopRequireDefault(require("./node_modules/chalk/source/index.js"));
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+ /*
32
+ The MIT License (MIT)
33
+
34
+ Copyright (c) 2015, 2017-2018, 2022 Blaine Bublitz <blaine.bublitz@gmail.com> and Eric Schoffstall <yo@contra.io>
35
+
36
+ Permission is hereby granted, free of charge, to any person obtaining a copy
37
+ of this software and associated documentation files (the "Software"), to deal
38
+ in the Software without restriction, including without limitation the rights
39
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40
+ copies of the Software, and to permit persons to whom the Software is
41
+ furnished to do so, subject to the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be included in all
44
+ copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
49
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
50
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
51
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52
+ SOFTWARE.
53
+ */
54
+
55
+ // Adapted from https://github.com/gulpjs/plugin-error 2.0.1
56
+
57
+ const nonEnum = ['message', 'name', 'stack'];
58
+ const ignored = new Set([...nonEnum, '__safety', '_stack', 'plugin', 'showProperties', 'showStack', 'domain', 'domainEmitter', 'domainThrown']);
59
+ const props = ['fileName', 'lineNumber', 'message', 'name', 'plugin', 'showProperties', 'showStack', 'stack'];
60
+ class PluginError extends Error {
61
+ constructor(plugin, message, options) {
62
+ super();
63
+ const options_ = setDefaults(plugin, message, options);
64
+ Object.assign(this, options_);
65
+ if (typeof options_.error === 'object') {
66
+ this.message = options_.error.message;
67
+ this.stack = options_.error.stack;
68
+ this.cause = options_.error.cause;
69
+ Object.assign(this, options_.error);
70
+ }
71
+ for (const prop of props) {
72
+ if (prop in options_) {
73
+ this[prop] = options_[prop];
74
+ }
75
+ }
76
+ if (!this.stack) {
77
+ const safety = {
78
+ toString: this._messageWithDetails.bind(this) + '\nStack:'
79
+ };
80
+ Error.captureStackTrace(safety, this.constructor);
81
+ this.__safety = safety;
82
+ }
83
+ if (!this.plugin) {
84
+ throw new Error('Missing plugin name');
85
+ }
86
+ if (!this.message) {
87
+ throw new Error('Missing error message');
88
+ }
89
+ if (message instanceof Error && options_.error.isPresentable) {
90
+ this.showStack = false;
91
+ this.showProperties = false;
92
+ }
93
+ }
94
+ _messageWithDetails() {
95
+ let message_ = "Message:\n ".concat(this.message);
96
+ const details = this._messageDetails();
97
+ if (details) {
98
+ message_ += "\n".concat(details);
99
+ }
100
+ return message_;
101
+ }
102
+ _messageDetails() {
103
+ if (!this.showProperties) {
104
+ return '';
105
+ }
106
+ const relevantProps = Object.keys(this).filter(key => !ignored.has(key));
107
+ return relevantProps.length > 0 ? "Details:\n".concat(relevantProps.map(prop => " ".concat(prop, ": ").concat(this[prop])).join('\n')) : '';
108
+ }
109
+ toString() {
110
+ const message_ = this.showStack ? this.__safety ? this.__safety.stack : this.stack : this._messageWithDetails();
111
+ return formatMessage(message_, this);
112
+ }
113
+ }
114
+ exports.default = PluginError;
115
+ function formatMessage(message, thisArg) {
116
+ return "".concat(_index.default.red(thisArg.name), " in plugin \"").concat(_index.default.cyan(thisArg.plugin), "\"\n").concat(message);
117
+ }
118
+ function setDefaults(plugin, message, options) {
119
+ if (typeof plugin === 'object') {
120
+ return {
121
+ ...plugin
122
+ };
123
+ }
124
+ if (message instanceof Error) {
125
+ options = {
126
+ ...options,
127
+ error: message
128
+ };
129
+ } else if (typeof message === 'object') {
130
+ options = {
131
+ ...message
132
+ };
133
+ } else {
134
+ options = {
135
+ ...options,
136
+ message
137
+ };
138
+ }
139
+ options.plugin = plugin;
140
+ return {
141
+ showStack: false,
142
+ showProperties: true,
143
+ ...options
144
+ };
145
145
  }