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.

26 lines
595 B

4 years ago
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. module.exports = class ResultPlugin {
  7. constructor(source) {
  8. this.source = source;
  9. }
  10. apply(resolver) {
  11. this.source.tapAsync(
  12. "ResultPlugin",
  13. (request, resolverContext, callback) => {
  14. const obj = Object.assign({}, request);
  15. if (resolverContext.log)
  16. resolverContext.log("reporting result " + obj.path);
  17. resolver.hooks.result.callAsync(obj, resolverContext, err => {
  18. if (err) return callback(err);
  19. callback(null, obj);
  20. });
  21. }
  22. );
  23. }
  24. };