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.

generateConfigFile.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _jestConfig() {
  7. const data = require('jest-config');
  8. _jestConfig = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. /**
  14. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  15. *
  16. * This source code is licensed under the MIT license found in the
  17. * LICENSE file in the root directory of this source tree.
  18. */
  19. const stringifyOption = (option, map, linePrefix = '') => {
  20. const optionDescription = ` // ${_jestConfig().descriptions[option]}`;
  21. const stringifiedObject = `${option}: ${JSON.stringify(
  22. map[option],
  23. null,
  24. 2
  25. )}`;
  26. return (
  27. optionDescription +
  28. '\n' +
  29. stringifiedObject
  30. .split('\n')
  31. .map(line => ' ' + linePrefix + line)
  32. .join('\n') +
  33. ',\n'
  34. );
  35. };
  36. const generateConfigFile = (results, generateEsm = false) => {
  37. const {useTypescript, coverage, coverageProvider, clearMocks, environment} =
  38. results;
  39. const overrides = {};
  40. if (coverage) {
  41. Object.assign(overrides, {
  42. collectCoverage: true,
  43. coverageDirectory: 'coverage'
  44. });
  45. }
  46. if (coverageProvider === 'v8') {
  47. Object.assign(overrides, {
  48. coverageProvider: 'v8'
  49. });
  50. }
  51. if (environment === 'jsdom') {
  52. Object.assign(overrides, {
  53. testEnvironment: 'jsdom'
  54. });
  55. }
  56. if (clearMocks) {
  57. Object.assign(overrides, {
  58. clearMocks: true
  59. });
  60. }
  61. const overrideKeys = Object.keys(overrides);
  62. const properties = [];
  63. for (const option in _jestConfig().descriptions) {
  64. const opt = option;
  65. if (overrideKeys.includes(opt)) {
  66. properties.push(stringifyOption(opt, overrides));
  67. } else {
  68. properties.push(stringifyOption(opt, _jestConfig().defaults, '// '));
  69. }
  70. }
  71. const configHeaderMessage = `/*
  72. * For a detailed explanation regarding each configuration property${
  73. useTypescript ? ' and type check' : ''
  74. }, visit:
  75. * https://jestjs.io/docs/configuration
  76. */
  77. `;
  78. return (
  79. configHeaderMessage +
  80. (useTypescript || generateEsm
  81. ? 'export default {\n'
  82. : 'module.exports = {\n') +
  83. properties.join('\n') +
  84. '};\n'
  85. );
  86. };
  87. var _default = generateConfigFile;
  88. exports.default = _default;