選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

createInnerCallback.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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(callback, options, message, messageOptional) {
  9. const log = options.log;
  10. if(!log) {
  11. if(options.stack !== callback.stack) {
  12. const callbackWrapper = function callbackWrapper() {
  13. return callback.apply(this, arguments);
  14. };
  15. callbackWrapper.stack = options.stack;
  16. callbackWrapper.missing = options.missing;
  17. return callbackWrapper;
  18. }
  19. return callback;
  20. }
  21. function loggingCallbackWrapper() {
  22. return callback.apply(this, arguments);
  23. }
  24. if(message) {
  25. if(!messageOptional) {
  26. log(message);
  27. }
  28. loggingCallbackWrapper.log = function writeLog(msg) {
  29. if(messageOptional) {
  30. log(message);
  31. messageOptional = false;
  32. }
  33. log(" " + msg);
  34. };
  35. } else {
  36. loggingCallbackWrapper.log = function writeLog(msg) {
  37. log(msg);
  38. };
  39. }
  40. loggingCallbackWrapper.stack = options.stack;
  41. loggingCallbackWrapper.missing = options.missing;
  42. return loggingCallbackWrapper;
  43. }, "Pass resolveContext instead and use createInnerContext");