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-warn-for-duplicates", function (options) {
|
27 | return function (style, result) {
|
28 |
|
29 | var keys = options.keys,
|
30 | messenger = options.console;
|
31 |
|
32 | var pluginNames = [];
|
33 | result.processor.plugins.forEach(function (plugin) {
|
34 | var name = plugin.postcssPlugin;
|
35 | if (pluginNames.indexOf(name) > -1 &&
|
36 |
|
37 | keys.indexOf(name) > -1 &&
|
38 |
|
39 | spotted.indexOf(name) === -1) {
|
40 | messenger.log(_chalk2.default.yellow.bold(msg(name)));
|
41 | spotted.push(name);
|
42 | } else {
|
43 | pluginNames.push(name);
|
44 | }
|
45 | });
|
46 |
|
47 | if (spotted.length > 0 && shouldGlobalWarn) {
|
48 | shouldGlobalWarn = false;
|
49 | messenger.log(globalWarning);
|
50 | }
|
51 | };
|
52 | });
|
53 |
|
54 | exports.default = warnForDuplicates; |
\ | No newline at end of file |