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.

formatTestNameByPattern.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _chalk() {
  7. const data = _interopRequireDefault(require('chalk'));
  8. _chalk = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. var _colorize = _interopRequireDefault(require('./colorize'));
  14. function _interopRequireDefault(obj) {
  15. return obj && obj.__esModule ? obj : {default: obj};
  16. }
  17. /**
  18. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  19. *
  20. * This source code is licensed under the MIT license found in the
  21. * LICENSE file in the root directory of this source tree.
  22. */
  23. const DOTS = '...';
  24. const ENTER = '⏎';
  25. var _default = (testName, pattern, width) => {
  26. const inlineTestName = testName.replace(/(\r\n|\n|\r)/gm, ENTER);
  27. let regexp;
  28. try {
  29. regexp = new RegExp(pattern, 'i');
  30. } catch {
  31. return _chalk().default.dim(inlineTestName);
  32. }
  33. const match = inlineTestName.match(regexp);
  34. if (!match) {
  35. return _chalk().default.dim(inlineTestName);
  36. }
  37. const startPatternIndex = Math.max(match.index || 0, 0);
  38. const endPatternIndex = startPatternIndex + match[0].length;
  39. if (inlineTestName.length <= width) {
  40. return (0, _colorize.default)(
  41. inlineTestName,
  42. startPatternIndex,
  43. endPatternIndex
  44. );
  45. }
  46. const slicedTestName = inlineTestName.slice(0, width - DOTS.length);
  47. if (startPatternIndex < slicedTestName.length) {
  48. if (endPatternIndex > slicedTestName.length) {
  49. return (0, _colorize.default)(
  50. slicedTestName + DOTS,
  51. startPatternIndex,
  52. slicedTestName.length + DOTS.length
  53. );
  54. } else {
  55. return (0, _colorize.default)(
  56. slicedTestName + DOTS,
  57. Math.min(startPatternIndex, slicedTestName.length),
  58. endPatternIndex
  59. );
  60. }
  61. }
  62. return `${_chalk().default.dim(slicedTestName)}${_chalk().default.reset(
  63. DOTS
  64. )}`;
  65. };
  66. exports.default = _default;