result.js 745 B

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