1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.spotted = undefined;
|
7 |
|
8 | var _postcss = require("postcss");
|
9 |
|
10 | var _postcss2 = _interopRequireDefault(_postcss);
|
11 |
|
12 | var _chalk = require("chalk");
|
13 |
|
14 | var _chalk2 = _interopRequireDefault(_chalk);
|
15 |
|
16 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17 |
|
18 | var msg = function msg(name) {
|
19 | return `Warning: postcss-cssnext found a duplicate plugin ('${name}') ` + "in your postcss plugins. " + `This might be inefficient. You should remove '${name}' from your ` + "postcss plugin list since it's already included by postcss-cssnext.";
|
20 | };
|
21 |
|
22 | var shouldGlobalWarn = true;
|
23 | var globalWarning = "Note: If, for a really specific reason, postcss-cssnext warnings are " + "irrelevant for your use case, and you really know what you are doing, " + "you can disable this warnings by setting 'warnForDuplicates' option of " + "postcss-cssnext to 'false'.";
|
24 | var spotted = exports.spotted = [];
|
25 |
|
26 | var warnForDuplicates = _postcss2.default.plugin("postcss-cssnext-warn-for-duplicates", function (_ref) {
|
27 | var keys = _ref.keys,
|
28 | messenger = _ref.console;
|
29 |
|
30 | return function (style, result) {
|
31 | var pluginNames = [];
|
32 | result.processor.plugins.forEach(function (plugin) {
|
33 | var name = plugin.postcssPlugin;
|
34 | if (pluginNames.indexOf(name) > -1 &&
|
35 |
|
36 | keys.indexOf(name) > -1 &&
|
37 |
|
38 | spotted.indexOf(name) === -1) {
|
39 | messenger.log(_chalk2.default.yellow.bold(msg(name)));
|
40 | spotted.push(name);
|
41 | } else {
|
42 | pluginNames.push(name);
|
43 | }
|
44 | });
|
45 |
|
46 | if (spotted.length > 0 && shouldGlobalWarn) {
|
47 | shouldGlobalWarn = false;
|
48 | messenger.log(globalWarning);
|
49 | }
|
50 | };
|
51 | });
|
52 |
|
53 | exports.default = warnForDuplicates; |
\ | No newline at end of file |