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

2 years ago
  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. toString() {
  13. return this.css
  14. }
  15. warn(text, opts = {}) {
  16. if (!opts.plugin) {
  17. if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
  18. opts.plugin = this.lastPlugin.postcssPlugin
  19. }
  20. }
  21. let warning = new Warning(text, opts)
  22. this.messages.push(warning)
  23. return warning
  24. }
  25. warnings() {
  26. return this.messages.filter(i => i.type === 'warning')
  27. }
  28. get content() {
  29. return this.css
  30. }
  31. }
  32. module.exports = Result
  33. Result.default = Result