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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. exports.runSync = exports.executeAsync = exports.executeSync = exports.hasWdioSyncSupport = exports.wrapCommand = exports.runFnInFiberContext = exports.executeHooksWithArgs = void 0;
  7. const logger_1 = __importDefault(require("@wdio/logger"));
  8. const log = logger_1.default('@wdio/utils:shim');
  9. let inCommandHook = false;
  10. let hasWdioSyncSupport = false;
  11. exports.hasWdioSyncSupport = hasWdioSyncSupport;
  12. let runSync;
  13. exports.runSync = runSync;
  14. let executeHooksWithArgs = async function executeHooksWithArgsShim(hookName, hooks = [], args = []) {
  15. if (!Array.isArray(hooks)) {
  16. hooks = [hooks];
  17. }
  18. if (!Array.isArray(args)) {
  19. args = [args];
  20. }
  21. const hooksPromises = hooks.map((hook) => new Promise((resolve) => {
  22. let result;
  23. try {
  24. result = hook.apply(null, args);
  25. }
  26. catch (e) {
  27. log.error(e.stack);
  28. return resolve(e);
  29. }
  30. if (result && typeof result.then === 'function') {
  31. return result.then(resolve, (e) => {
  32. log.error(e.stack);
  33. resolve(e);
  34. });
  35. }
  36. resolve(result);
  37. }));
  38. const start = Date.now();
  39. const result = await Promise.all(hooksPromises);
  40. if (hooksPromises.length) {
  41. log.debug(`Finished to run "${hookName}" hook in ${Date.now() - start}ms`);
  42. }
  43. return result;
  44. };
  45. exports.executeHooksWithArgs = executeHooksWithArgs;
  46. let runFnInFiberContext = function (fn) {
  47. return function (...args) {
  48. return Promise.resolve(fn.apply(this, args));
  49. };
  50. };
  51. exports.runFnInFiberContext = runFnInFiberContext;
  52. let wrapCommand = function wrapCommand(commandName, fn) {
  53. return async function wrapCommandFn(...args) {
  54. const beforeHookArgs = [commandName, args];
  55. if (!inCommandHook && this.options.beforeCommand) {
  56. inCommandHook = true;
  57. await executeHooksWithArgs.call(this, 'beforeCommand', this.options.beforeCommand, beforeHookArgs);
  58. inCommandHook = false;
  59. }
  60. let commandResult;
  61. let commandError;
  62. try {
  63. commandResult = await fn.apply(this, args);
  64. }
  65. catch (err) {
  66. commandError = err;
  67. }
  68. if (!inCommandHook && this.options.afterCommand) {
  69. inCommandHook = true;
  70. const afterHookArgs = [...beforeHookArgs, commandResult, commandError];
  71. await executeHooksWithArgs.call(this, 'afterCommand', this.options.afterCommand, afterHookArgs);
  72. inCommandHook = false;
  73. }
  74. if (commandError) {
  75. throw commandError;
  76. }
  77. return commandResult;
  78. };
  79. };
  80. exports.wrapCommand = wrapCommand;
  81. async function executeSyncFn(fn, retries, args = []) {
  82. this.wdioRetries = retries.attempts;
  83. try {
  84. let res = fn.apply(this, args);
  85. if (res instanceof Promise) {
  86. return await res;
  87. }
  88. return res;
  89. }
  90. catch (e) {
  91. if (retries.limit > retries.attempts) {
  92. retries.attempts++;
  93. return await executeSync.call(this, fn, retries, args);
  94. }
  95. return Promise.reject(e);
  96. }
  97. }
  98. async function executeAsync(fn, retries, args = []) {
  99. this.wdioRetries = retries.attempts;
  100. try {
  101. return await fn.apply(this, args);
  102. }
  103. catch (e) {
  104. if (retries.limit > retries.attempts) {
  105. retries.attempts++;
  106. return await executeAsync.call(this, fn, retries, args);
  107. }
  108. throw e;
  109. }
  110. }
  111. exports.executeAsync = executeAsync;
  112. let executeSync = executeSyncFn;
  113. exports.executeSync = executeSync;
  114. try {
  115. if (!process.env.WDIO_NO_SYNC_SUPPORT) {
  116. const packageName = '@wdio/sync';
  117. const wdioSync = require(packageName);
  118. exports.hasWdioSyncSupport = hasWdioSyncSupport = true;
  119. exports.runFnInFiberContext = runFnInFiberContext = wdioSync.runFnInFiberContext;
  120. exports.wrapCommand = wrapCommand = wdioSync.wrapCommand;
  121. exports.executeHooksWithArgs = executeHooksWithArgs = wdioSync.executeHooksWithArgs;
  122. exports.executeSync = executeSync = wdioSync.executeSync;
  123. exports.runSync = runSync = wdioSync.runSync;
  124. }
  125. }
  126. catch (_a) {
  127. }