UNPKG

750 BJavaScriptView Raw
1'use strict'
2
3let Warning = require('./warning')
4
5class Result {
6 constructor (processor, root, opts) {
7 this.processor = processor
8 this.messages = []
9 this.root = root
10 this.opts = opts
11 this.css = undefined
12 this.map = undefined
13 }
14
15 toString () {
16 return this.css
17 }
18
19 warn (text, opts = {}) {
20 if (!opts.plugin) {
21 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
22 opts.plugin = this.lastPlugin.postcssPlugin
23 }
24 }
25
26 let warning = new Warning(text, opts)
27 this.messages.push(warning)
28
29 return warning
30 }
31
32 warnings () {
33 return this.messages.filter(i => i.type === 'warning')
34 }
35
36 get content () {
37 return this.css
38 }
39}
40
41module.exports = Result
42Result.default = Result