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.

index.js 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.run = run;
  6. exports.buildArgv = void 0;
  7. function path() {
  8. const data = _interopRequireWildcard(require('path'));
  9. path = function () {
  10. return data;
  11. };
  12. return data;
  13. }
  14. function _chalk() {
  15. const data = _interopRequireDefault(require('chalk'));
  16. _chalk = function () {
  17. return data;
  18. };
  19. return data;
  20. }
  21. function _exit() {
  22. const data = _interopRequireDefault(require('exit'));
  23. _exit = function () {
  24. return data;
  25. };
  26. return data;
  27. }
  28. function _yargs() {
  29. const data = _interopRequireDefault(require('yargs'));
  30. _yargs = function () {
  31. return data;
  32. };
  33. return data;
  34. }
  35. function _core() {
  36. const data = require('@jest/core');
  37. _core = function () {
  38. return data;
  39. };
  40. return data;
  41. }
  42. function _jestConfig() {
  43. const data = require('jest-config');
  44. _jestConfig = function () {
  45. return data;
  46. };
  47. return data;
  48. }
  49. function _jestUtil() {
  50. const data = require('jest-util');
  51. _jestUtil = function () {
  52. return data;
  53. };
  54. return data;
  55. }
  56. function _jestValidate() {
  57. const data = require('jest-validate');
  58. _jestValidate = function () {
  59. return data;
  60. };
  61. return data;
  62. }
  63. function _init() {
  64. const data = _interopRequireDefault(require('../init'));
  65. _init = function () {
  66. return data;
  67. };
  68. return data;
  69. }
  70. var args = _interopRequireWildcard(require('./args'));
  71. function _interopRequireDefault(obj) {
  72. return obj && obj.__esModule ? obj : {default: obj};
  73. }
  74. function _getRequireWildcardCache(nodeInterop) {
  75. if (typeof WeakMap !== 'function') return null;
  76. var cacheBabelInterop = new WeakMap();
  77. var cacheNodeInterop = new WeakMap();
  78. return (_getRequireWildcardCache = function (nodeInterop) {
  79. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  80. })(nodeInterop);
  81. }
  82. function _interopRequireWildcard(obj, nodeInterop) {
  83. if (!nodeInterop && obj && obj.__esModule) {
  84. return obj;
  85. }
  86. if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
  87. return {default: obj};
  88. }
  89. var cache = _getRequireWildcardCache(nodeInterop);
  90. if (cache && cache.has(obj)) {
  91. return cache.get(obj);
  92. }
  93. var newObj = {};
  94. var hasPropertyDescriptor =
  95. Object.defineProperty && Object.getOwnPropertyDescriptor;
  96. for (var key in obj) {
  97. if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
  98. var desc = hasPropertyDescriptor
  99. ? Object.getOwnPropertyDescriptor(obj, key)
  100. : null;
  101. if (desc && (desc.get || desc.set)) {
  102. Object.defineProperty(newObj, key, desc);
  103. } else {
  104. newObj[key] = obj[key];
  105. }
  106. }
  107. }
  108. newObj.default = obj;
  109. if (cache) {
  110. cache.set(obj, newObj);
  111. }
  112. return newObj;
  113. }
  114. /**
  115. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  116. *
  117. * This source code is licensed under the MIT license found in the
  118. * LICENSE file in the root directory of this source tree.
  119. */
  120. async function run(maybeArgv, project) {
  121. try {
  122. const argv = buildArgv(maybeArgv);
  123. if (argv.init) {
  124. await (0, _init().default)();
  125. return;
  126. }
  127. const projects = getProjectListFromCLIArgs(argv, project);
  128. const {results, globalConfig} = await (0, _core().runCLI)(argv, projects);
  129. readResultsAndExit(results, globalConfig);
  130. } catch (error) {
  131. (0, _jestUtil().clearLine)(process.stderr);
  132. (0, _jestUtil().clearLine)(process.stdout);
  133. if (error !== null && error !== void 0 && error.stack) {
  134. console.error(_chalk().default.red(error.stack));
  135. } else {
  136. console.error(_chalk().default.red(error));
  137. }
  138. (0, _exit().default)(1);
  139. throw error;
  140. }
  141. }
  142. const buildArgv = maybeArgv => {
  143. const version =
  144. (0, _core().getVersion)() +
  145. (__dirname.includes(`packages${path().sep}jest-cli`) ? '-dev' : '');
  146. const rawArgv = maybeArgv || process.argv.slice(2);
  147. const argv = (0, _yargs().default)(rawArgv)
  148. .usage(args.usage)
  149. .version(version)
  150. .alias('help', 'h')
  151. .options(args.options)
  152. .epilogue(args.docs)
  153. .check(args.check).argv;
  154. (0, _jestValidate().validateCLIOptions)(
  155. argv,
  156. {...args.options, deprecationEntries: _jestConfig().deprecationEntries}, // strip leading dashes
  157. Array.isArray(rawArgv)
  158. ? rawArgv.map(rawArgv => rawArgv.replace(/^--?/, ''))
  159. : Object.keys(rawArgv)
  160. ); // strip dashed args
  161. return Object.keys(argv).reduce(
  162. (result, key) => {
  163. if (!key.includes('-')) {
  164. result[key] = argv[key];
  165. }
  166. return result;
  167. },
  168. {
  169. $0: argv.$0,
  170. _: argv._
  171. }
  172. );
  173. };
  174. exports.buildArgv = buildArgv;
  175. const getProjectListFromCLIArgs = (argv, project) => {
  176. const projects = argv.projects ? argv.projects : [];
  177. if (project) {
  178. projects.push(project);
  179. }
  180. if (!projects.length && process.platform === 'win32') {
  181. try {
  182. projects.push((0, _jestUtil().tryRealpath)(process.cwd()));
  183. } catch {
  184. // do nothing, just catch error
  185. // process.binding('fs').realpath can throw, e.g. on mapped drives
  186. }
  187. }
  188. if (!projects.length) {
  189. projects.push(process.cwd());
  190. }
  191. return projects;
  192. };
  193. const readResultsAndExit = (result, globalConfig) => {
  194. const code = !result || result.success ? 0 : globalConfig.testFailureExitCode; // Only exit if needed
  195. process.on('exit', () => {
  196. if (typeof code === 'number' && code !== 0) {
  197. process.exitCode = code;
  198. }
  199. });
  200. if (globalConfig.forceExit) {
  201. if (!globalConfig.detectOpenHandles) {
  202. console.warn(
  203. _chalk().default.bold('Force exiting Jest: ') +
  204. 'Have you considered using `--detectOpenHandles` to detect ' +
  205. 'async operations that kept running after all tests finished?'
  206. );
  207. }
  208. (0, _exit().default)(code);
  209. } else if (!globalConfig.detectOpenHandles) {
  210. setTimeout(() => {
  211. console.warn(
  212. _chalk().default.yellow.bold(
  213. 'Jest did not exit one second after the test run has completed.\n\n'
  214. ) +
  215. _chalk().default.yellow(
  216. 'This usually means that there are asynchronous operations that ' +
  217. "weren't stopped in your tests. Consider running Jest with " +
  218. '`--detectOpenHandles` to troubleshoot this issue.'
  219. )
  220. );
  221. }, 1000).unref();
  222. }
  223. };