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.

helpers.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.findSiblingsWithFileExtension =
  6. exports.decodePossibleOutsideJestVmPath =
  7. exports.createOutsideJestVmPath =
  8. void 0;
  9. function path() {
  10. const data = _interopRequireWildcard(require('path'));
  11. path = function () {
  12. return data;
  13. };
  14. return data;
  15. }
  16. function _glob() {
  17. const data = _interopRequireDefault(require('glob'));
  18. _glob = function () {
  19. return data;
  20. };
  21. return data;
  22. }
  23. function _slash() {
  24. const data = _interopRequireDefault(require('slash'));
  25. _slash = function () {
  26. return data;
  27. };
  28. return data;
  29. }
  30. function _interopRequireDefault(obj) {
  31. return obj && obj.__esModule ? obj : {default: obj};
  32. }
  33. function _getRequireWildcardCache(nodeInterop) {
  34. if (typeof WeakMap !== 'function') return null;
  35. var cacheBabelInterop = new WeakMap();
  36. var cacheNodeInterop = new WeakMap();
  37. return (_getRequireWildcardCache = function (nodeInterop) {
  38. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  39. })(nodeInterop);
  40. }
  41. function _interopRequireWildcard(obj, nodeInterop) {
  42. if (!nodeInterop && obj && obj.__esModule) {
  43. return obj;
  44. }
  45. if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
  46. return {default: obj};
  47. }
  48. var cache = _getRequireWildcardCache(nodeInterop);
  49. if (cache && cache.has(obj)) {
  50. return cache.get(obj);
  51. }
  52. var newObj = {};
  53. var hasPropertyDescriptor =
  54. Object.defineProperty && Object.getOwnPropertyDescriptor;
  55. for (var key in obj) {
  56. if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
  57. var desc = hasPropertyDescriptor
  58. ? Object.getOwnPropertyDescriptor(obj, key)
  59. : null;
  60. if (desc && (desc.get || desc.set)) {
  61. Object.defineProperty(newObj, key, desc);
  62. } else {
  63. newObj[key] = obj[key];
  64. }
  65. }
  66. }
  67. newObj.default = obj;
  68. if (cache) {
  69. cache.set(obj, newObj);
  70. }
  71. return newObj;
  72. }
  73. /**
  74. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  75. *
  76. * This source code is licensed under the MIT license found in the
  77. * LICENSE file in the root directory of this source tree.
  78. */
  79. const OUTSIDE_JEST_VM_PROTOCOL = 'jest-main:'; // String manipulation is easier here, fileURLToPath is only in newer Nodes,
  80. // plus setting non-standard protocols on URL objects is difficult.
  81. const createOutsideJestVmPath = path =>
  82. OUTSIDE_JEST_VM_PROTOCOL + '//' + encodeURIComponent(path);
  83. exports.createOutsideJestVmPath = createOutsideJestVmPath;
  84. const decodePossibleOutsideJestVmPath = outsideJestVmPath => {
  85. if (outsideJestVmPath.startsWith(OUTSIDE_JEST_VM_PROTOCOL)) {
  86. return decodeURIComponent(
  87. outsideJestVmPath.replace(
  88. new RegExp('^' + OUTSIDE_JEST_VM_PROTOCOL + '//'),
  89. ''
  90. )
  91. );
  92. }
  93. return undefined;
  94. };
  95. exports.decodePossibleOutsideJestVmPath = decodePossibleOutsideJestVmPath;
  96. const findSiblingsWithFileExtension = (
  97. moduleFileExtensions,
  98. from,
  99. moduleName
  100. ) => {
  101. if (!path().isAbsolute(moduleName) && path().extname(moduleName) === '') {
  102. const dirname = path().dirname(from);
  103. const pathToModule = path().resolve(dirname, moduleName);
  104. try {
  105. const slashedDirname = (0, _slash().default)(dirname);
  106. const matches = _glob()
  107. .default.sync(`${pathToModule}.*`)
  108. .map(match => (0, _slash().default)(match))
  109. .map(match => {
  110. const relativePath = path().posix.relative(slashedDirname, match);
  111. return path().posix.dirname(match) === slashedDirname
  112. ? `./${relativePath}`
  113. : relativePath;
  114. })
  115. .map(match => `\t'${match}'`)
  116. .join('\n');
  117. if (matches) {
  118. const foundMessage = `\n\nHowever, Jest was able to find:\n${matches}`;
  119. const mappedModuleFileExtensions = moduleFileExtensions
  120. .map(ext => `'${ext}'`)
  121. .join(', ');
  122. return (
  123. foundMessage +
  124. "\n\nYou might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently " +
  125. `[${mappedModuleFileExtensions}].\n\nSee https://jestjs.io/docs/configuration#modulefileextensions-arraystring`
  126. );
  127. }
  128. } catch {}
  129. }
  130. return '';
  131. };
  132. exports.findSiblingsWithFileExtension = findSiblingsWithFileExtension;