Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

debug.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const serialize_error_1 = require("serialize-error");
  7. const repl_1 = __importDefault(require("@wdio/repl"));
  8. function debug(commandTimeout = 5000) {
  9. const repl = new repl_1.default();
  10. const { introMessage } = repl_1.default;
  11. if (!process.env.WDIO_WORKER || typeof process.send !== 'function') {
  12. console.log(repl_1.default.introMessage);
  13. const context = {
  14. browser: this,
  15. driver: this,
  16. $: this.$.bind(this),
  17. $$: this.$$.bind(this)
  18. };
  19. return repl.start(context);
  20. }
  21. process._debugProcess(process.pid);
  22. process.send({
  23. origin: 'debugger',
  24. name: 'start',
  25. params: { commandTimeout, introMessage }
  26. });
  27. let commandResolve = () => { };
  28. process.on('message', (m) => {
  29. if (m.origin !== 'debugger') {
  30. return;
  31. }
  32. if (m.name === 'stop') {
  33. process._debugEnd(process.pid);
  34. return commandResolve();
  35. }
  36. if (m.name === 'eval') {
  37. repl.eval(m.content.cmd, global, undefined, (err, result) => {
  38. if (typeof process.send !== 'function') {
  39. return;
  40. }
  41. if (err) {
  42. process.send({
  43. origin: 'debugger',
  44. name: 'result',
  45. params: {
  46. error: true,
  47. ...serialize_error_1.serializeError(err)
  48. }
  49. });
  50. }
  51. if (typeof result === 'function') {
  52. result = `[Function: ${result.name}]`;
  53. }
  54. process.send({
  55. origin: 'debugger',
  56. name: 'result',
  57. params: { result }
  58. });
  59. });
  60. }
  61. });
  62. return new Promise((resolve) => (commandResolve = resolve));
  63. }
  64. exports.default = debug;