MCPcopy
hub / github.com/postcss/postcss / runOnRoot

Method runOnRoot

lib/lazy-result.js:343–366  ·  view source on GitHub ↗
(plugin)

Source from the content-addressed store, hash-verified

341 }
342
343 runOnRoot(plugin) {
344 this.result.lastPlugin = plugin
345 try {
346 if (typeof plugin === 'object' && plugin.Once) {
347 if (this.result.root.type === 'document') {
348 let roots = this.result.root.nodes.map(root =>
349 plugin.Once(root, this.helpers)
350 )
351
352 if (isPromise(roots[0])) {
353 return Promise.all(roots)
354 }
355
356 return roots
357 }
358
359 return plugin.Once(this.result.root, this.helpers)
360 } else if (typeof plugin === 'function') {
361 return plugin(this.result.root, this.result)
362 }
363 } catch (error) {
364 throw this.handleError(error)
365 }
366 }
367
368 stringify() {
369 if (this.error) throw this.error

Callers 2

runAsyncMethod · 0.95
syncMethod · 0.95

Calls 4

handleErrorMethod · 0.95
isPromiseFunction · 0.85
pluginFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected