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.

defaultResolver.js 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = defaultResolver;
  6. exports.clearDefaultResolverCache = clearDefaultResolverCache;
  7. function fs() {
  8. const data = _interopRequireWildcard(require('graceful-fs'));
  9. fs = function () {
  10. return data;
  11. };
  12. return data;
  13. }
  14. function _jestPnpResolver() {
  15. const data = _interopRequireDefault(require('jest-pnp-resolver'));
  16. _jestPnpResolver = function () {
  17. return data;
  18. };
  19. return data;
  20. }
  21. function _resolve() {
  22. const data = require('resolve');
  23. _resolve = function () {
  24. return data;
  25. };
  26. return data;
  27. }
  28. function _jestUtil() {
  29. const data = require('jest-util');
  30. _jestUtil = function () {
  31. return data;
  32. };
  33. return data;
  34. }
  35. function _interopRequireDefault(obj) {
  36. return obj && obj.__esModule ? obj : {default: obj};
  37. }
  38. function _getRequireWildcardCache(nodeInterop) {
  39. if (typeof WeakMap !== 'function') return null;
  40. var cacheBabelInterop = new WeakMap();
  41. var cacheNodeInterop = new WeakMap();
  42. return (_getRequireWildcardCache = function (nodeInterop) {
  43. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  44. })(nodeInterop);
  45. }
  46. function _interopRequireWildcard(obj, nodeInterop) {
  47. if (!nodeInterop && obj && obj.__esModule) {
  48. return obj;
  49. }
  50. if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
  51. return {default: obj};
  52. }
  53. var cache = _getRequireWildcardCache(nodeInterop);
  54. if (cache && cache.has(obj)) {
  55. return cache.get(obj);
  56. }
  57. var newObj = {};
  58. var hasPropertyDescriptor =
  59. Object.defineProperty && Object.getOwnPropertyDescriptor;
  60. for (var key in obj) {
  61. if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
  62. var desc = hasPropertyDescriptor
  63. ? Object.getOwnPropertyDescriptor(obj, key)
  64. : null;
  65. if (desc && (desc.get || desc.set)) {
  66. Object.defineProperty(newObj, key, desc);
  67. } else {
  68. newObj[key] = obj[key];
  69. }
  70. }
  71. }
  72. newObj.default = obj;
  73. if (cache) {
  74. cache.set(obj, newObj);
  75. }
  76. return newObj;
  77. }
  78. /**
  79. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  80. *
  81. * This source code is licensed under the MIT license found in the
  82. * LICENSE file in the root directory of this source tree.
  83. */
  84. function defaultResolver(path, options) {
  85. // Yarn 2 adds support to `resolve` automatically so the pnpResolver is only
  86. // needed for Yarn 1 which implements version 1 of the pnp spec
  87. if (process.versions.pnp === '1') {
  88. return (0, _jestPnpResolver().default)(path, options);
  89. }
  90. const result = (0, _resolve().sync)(path, {
  91. ...options,
  92. isDirectory,
  93. isFile,
  94. preserveSymlinks: false,
  95. readPackageSync,
  96. realpathSync
  97. }); // Dereference symlinks to ensure we don't create a separate
  98. // module instance depending on how it was referenced.
  99. return realpathSync(result);
  100. }
  101. function clearDefaultResolverCache() {
  102. checkedPaths.clear();
  103. checkedRealpathPaths.clear();
  104. packageContents.clear();
  105. }
  106. var IPathType;
  107. (function (IPathType) {
  108. IPathType[(IPathType['FILE'] = 1)] = 'FILE';
  109. IPathType[(IPathType['DIRECTORY'] = 2)] = 'DIRECTORY';
  110. IPathType[(IPathType['OTHER'] = 3)] = 'OTHER';
  111. })(IPathType || (IPathType = {}));
  112. const checkedPaths = new Map();
  113. function statSyncCached(path) {
  114. const result = checkedPaths.get(path);
  115. if (result !== undefined) {
  116. return result;
  117. }
  118. let stat;
  119. try {
  120. stat = fs().statSync(path);
  121. } catch (e) {
  122. if (!(e && (e.code === 'ENOENT' || e.code === 'ENOTDIR'))) {
  123. throw e;
  124. }
  125. }
  126. if (stat) {
  127. if (stat.isFile() || stat.isFIFO()) {
  128. checkedPaths.set(path, IPathType.FILE);
  129. return IPathType.FILE;
  130. } else if (stat.isDirectory()) {
  131. checkedPaths.set(path, IPathType.DIRECTORY);
  132. return IPathType.DIRECTORY;
  133. }
  134. }
  135. checkedPaths.set(path, IPathType.OTHER);
  136. return IPathType.OTHER;
  137. }
  138. const checkedRealpathPaths = new Map();
  139. function realpathCached(path) {
  140. let result = checkedRealpathPaths.get(path);
  141. if (result !== undefined) {
  142. return result;
  143. }
  144. result = (0, _jestUtil().tryRealpath)(path);
  145. checkedRealpathPaths.set(path, result);
  146. if (path !== result) {
  147. // also cache the result in case it's ever referenced directly - no reason to `realpath` that as well
  148. checkedRealpathPaths.set(result, result);
  149. }
  150. return result;
  151. }
  152. const packageContents = new Map();
  153. function readPackageCached(path) {
  154. let result = packageContents.get(path);
  155. if (result !== undefined) {
  156. return result;
  157. }
  158. result = JSON.parse(fs().readFileSync(path, 'utf8'));
  159. packageContents.set(path, result);
  160. return result;
  161. }
  162. /*
  163. * helper functions
  164. */
  165. function isFile(file) {
  166. return statSyncCached(file) === IPathType.FILE;
  167. }
  168. function isDirectory(dir) {
  169. return statSyncCached(dir) === IPathType.DIRECTORY;
  170. }
  171. function realpathSync(file) {
  172. return realpathCached(file);
  173. }
  174. function readPackageSync(_, file) {
  175. return readPackageCached(file);
  176. }