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.

partial.js 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = loadPrivatePartialConfig;
  6. exports.loadPartialConfig = void 0;
  7. function _path() {
  8. const data = require("path");
  9. _path = function () {
  10. return data;
  11. };
  12. return data;
  13. }
  14. function _gensync() {
  15. const data = require("gensync");
  16. _gensync = function () {
  17. return data;
  18. };
  19. return data;
  20. }
  21. var _plugin = require("./plugin");
  22. var _util = require("./util");
  23. var _item = require("./item");
  24. var _configChain = require("./config-chain");
  25. var _environment = require("./helpers/environment");
  26. var _options = require("./validation/options");
  27. var _files = require("./files");
  28. var _resolveTargets = require("./resolve-targets");
  29. function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  30. function resolveRootMode(rootDir, rootMode) {
  31. switch (rootMode) {
  32. case "root":
  33. return rootDir;
  34. case "upward-optional":
  35. {
  36. const upwardRootDir = (0, _files.findConfigUpwards)(rootDir);
  37. return upwardRootDir === null ? rootDir : upwardRootDir;
  38. }
  39. case "upward":
  40. {
  41. const upwardRootDir = (0, _files.findConfigUpwards)(rootDir);
  42. if (upwardRootDir !== null) return upwardRootDir;
  43. throw Object.assign(new Error(`Babel was run with rootMode:"upward" but a root could not ` + `be found when searching upward from "${rootDir}".\n` + `One of the following config files must be in the directory tree: ` + `"${_files.ROOT_CONFIG_FILENAMES.join(", ")}".`), {
  44. code: "BABEL_ROOT_NOT_FOUND",
  45. dirname: rootDir
  46. });
  47. }
  48. default:
  49. throw new Error(`Assertion failure - unknown rootMode value.`);
  50. }
  51. }
  52. function* loadPrivatePartialConfig(inputOpts) {
  53. if (inputOpts != null && (typeof inputOpts !== "object" || Array.isArray(inputOpts))) {
  54. throw new Error("Babel options must be an object, null, or undefined");
  55. }
  56. const args = inputOpts ? (0, _options.validate)("arguments", inputOpts) : {};
  57. const {
  58. envName = (0, _environment.getEnv)(),
  59. cwd = ".",
  60. root: rootDir = ".",
  61. rootMode = "root",
  62. caller,
  63. cloneInputAst = true
  64. } = args;
  65. const absoluteCwd = _path().resolve(cwd);
  66. const absoluteRootDir = resolveRootMode(_path().resolve(absoluteCwd, rootDir), rootMode);
  67. const filename = typeof args.filename === "string" ? _path().resolve(cwd, args.filename) : undefined;
  68. const showConfigPath = yield* (0, _files.resolveShowConfigPath)(absoluteCwd);
  69. const context = {
  70. filename,
  71. cwd: absoluteCwd,
  72. root: absoluteRootDir,
  73. envName,
  74. caller,
  75. showConfig: showConfigPath === filename
  76. };
  77. const configChain = yield* (0, _configChain.buildRootChain)(args, context);
  78. if (!configChain) return null;
  79. const merged = {
  80. assumptions: {}
  81. };
  82. configChain.options.forEach(opts => {
  83. (0, _util.mergeOptions)(merged, opts);
  84. });
  85. const options = Object.assign({}, merged, {
  86. targets: (0, _resolveTargets.resolveTargets)(merged, absoluteRootDir),
  87. cloneInputAst,
  88. babelrc: false,
  89. configFile: false,
  90. browserslistConfigFile: false,
  91. passPerPreset: false,
  92. envName: context.envName,
  93. cwd: context.cwd,
  94. root: context.root,
  95. rootMode: "root",
  96. filename: typeof context.filename === "string" ? context.filename : undefined,
  97. plugins: configChain.plugins.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)),
  98. presets: configChain.presets.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor))
  99. });
  100. return {
  101. options,
  102. context,
  103. fileHandling: configChain.fileHandling,
  104. ignore: configChain.ignore,
  105. babelrc: configChain.babelrc,
  106. config: configChain.config,
  107. files: configChain.files
  108. };
  109. }
  110. const loadPartialConfig = _gensync()(function* (opts) {
  111. let showIgnoredFiles = false;
  112. if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) {
  113. var _opts = opts;
  114. ({
  115. showIgnoredFiles
  116. } = _opts);
  117. opts = _objectWithoutPropertiesLoose(_opts, ["showIgnoredFiles"]);
  118. _opts;
  119. }
  120. const result = yield* loadPrivatePartialConfig(opts);
  121. if (!result) return null;
  122. const {
  123. options,
  124. babelrc,
  125. ignore,
  126. config,
  127. fileHandling,
  128. files
  129. } = result;
  130. if (fileHandling === "ignored" && !showIgnoredFiles) {
  131. return null;
  132. }
  133. (options.plugins || []).forEach(item => {
  134. if (item.value instanceof _plugin.default) {
  135. throw new Error("Passing cached plugin instances is not supported in " + "babel.loadPartialConfig()");
  136. }
  137. });
  138. return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined, fileHandling, files);
  139. });
  140. exports.loadPartialConfig = loadPartialConfig;
  141. class PartialConfig {
  142. constructor(options, babelrc, ignore, config, fileHandling, files) {
  143. this.options = void 0;
  144. this.babelrc = void 0;
  145. this.babelignore = void 0;
  146. this.config = void 0;
  147. this.fileHandling = void 0;
  148. this.files = void 0;
  149. this.options = options;
  150. this.babelignore = ignore;
  151. this.babelrc = babelrc;
  152. this.config = config;
  153. this.fileHandling = fileHandling;
  154. this.files = files;
  155. Object.freeze(this);
  156. }
  157. hasFilesystemConfig() {
  158. return this.babelrc !== undefined || this.config !== undefined;
  159. }
  160. }
  161. Object.freeze(PartialConfig.prototype);