result.js 738 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict'
  2. let Warning = require('./warning')
  3. class Result {
  4. get content() {
  5. return this.css
  6. }
  7. constructor(processor, root, opts) {
  8. this.processor = processor
  9. this.messages = []
  10. this.root = root
  11. this.opts = opts
  12. this.css = ''
  13. this.map = undefined
  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