MCPcopy
hub / github.com/postcss/postcss / normalize

Method normalize

lib/processor.js:14–42  ·  view source on GitHub ↗
(plugins)

Source from the content-addressed store, hash-verified

12 }
13
14 normalize(plugins) {
15 let normalized = []
16 for (let i of plugins) {
17 if (i.postcss === true) {
18 i = i()
19 } else if (i.postcss) {
20 i = i.postcss
21 }
22
23 if (typeof i === 'object' && Array.isArray(i.plugins)) {
24 normalized = normalized.concat(i.plugins)
25 } else if (typeof i === 'object' && i.postcssPlugin) {
26 normalized.push(i)
27 } else if (typeof i === 'function') {
28 normalized.push(i)
29 } else if (typeof i === 'object' && (i.parse || i.stringify)) {
30 if (process.env.NODE_ENV !== 'production') {
31 throw new Error(
32 'PostCSS syntaxes cannot be used as plugins. Instead, please use ' +
33 'one of the syntax/parser/stringifier options as outlined ' +
34 'in your PostCSS runner documentation.'
35 )
36 }
37 } else {
38 throw new Error(i + ' is not a PostCSS plugin')
39 }
40 }
41 return normalized
42 }
43
44 process(css, opts = {}) {
45 if (

Callers 2

constructorMethod · 0.95
useMethod · 0.95

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected