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.

52 lines
1.2 KiB

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. const util = require("util");
  7. // TODO remove in enhanced-resolve 5
  8. module.exports = util.deprecate(function createInnerCallback(
  9. callback,
  10. options,
  11. message,
  12. messageOptional
  13. ) {
  14. const log = options.log;
  15. if (!log) {
  16. if (options.stack !== callback.stack) {
  17. const callbackWrapper = function callbackWrapper() {
  18. return callback.apply(this, arguments);
  19. };
  20. callbackWrapper.stack = options.stack;
  21. callbackWrapper.missing = options.missing;
  22. return callbackWrapper;
  23. }
  24. return callback;
  25. }
  26. function loggingCallbackWrapper() {
  27. return callback.apply(this, arguments);
  28. }
  29. if (message) {
  30. if (!messageOptional) {
  31. log(message);
  32. }
  33. loggingCallbackWrapper.log = function writeLog(msg) {
  34. if (messageOptional) {
  35. log(message);
  36. messageOptional = false;
  37. }
  38. log(" " + msg);
  39. };
  40. } else {
  41. loggingCallbackWrapper.log = function writeLog(msg) {
  42. log(msg);
  43. };
  44. }
  45. loggingCallbackWrapper.stack = options.stack;
  46. loggingCallbackWrapper.missing = options.missing;
  47. return loggingCallbackWrapper;
  48. },
  49. "Pass resolveContext instead and use createInnerContext");