createInnerContext.js 757 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. module.exports = function createInnerContext(
  7. options,
  8. message,
  9. messageOptional
  10. ) {
  11. let messageReported = false;
  12. let innerLog = undefined;
  13. if (options.log) {
  14. if (message) {
  15. innerLog = msg => {
  16. if (!messageReported) {
  17. options.log(message);
  18. messageReported = true;
  19. }
  20. options.log(" " + msg);
  21. };
  22. } else {
  23. innerLog = options.log;
  24. }
  25. }
  26. const childContext = {
  27. log: innerLog,
  28. yield: options.yield,
  29. fileDependencies: options.fileDependencies,
  30. contextDependencies: options.contextDependencies,
  31. missingDependencies: options.missingDependencies,
  32. stack: options.stack
  33. };
  34. return childContext;
  35. };