createInnerContext.js 616 B

123456789101112131415161718192021222324252627282930
  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. const childContext = {
  13. log: (() => {
  14. if (!options.log) return undefined;
  15. if (!message) return options.log;
  16. const logFunction = msg => {
  17. if (!messageReported) {
  18. options.log(message);
  19. messageReported = true;
  20. }
  21. options.log(" " + msg);
  22. };
  23. return logFunction;
  24. })(),
  25. stack: options.stack,
  26. missing: options.missing
  27. };
  28. return childContext;
  29. };