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.

30 lines
616 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 = 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. };