You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
745 B

  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 = undefined
  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