UNPKG

745 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 get content() {
16 return this.css
17 }
18
19 toString() {
20 return this.css
21 }
22
23 warn(text, opts = {}) {
24 if (!opts.plugin) {
25 if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
26 opts.plugin = this.lastPlugin.postcssPlugin
27 }
28 }
29
30 let warning = new Warning(text, opts)
31 this.messages.push(warning)
32
33 return warning
34 }
35
36 warnings() {
37 return this.messages.filter(i => i.type === 'warning')
38 }
39}
40
41module.exports = Result
42Result.default = Result