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.

getConfigForFile.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. const augmentConfigFull = require('./augmentConfig').augmentConfigFull;
  3. const configurationError = require('./utils/configurationError');
  4. const path = require('path');
  5. /** @typedef {import('stylelint').StylelintConfig} StylelintConfig */
  6. /** @typedef {import('stylelint').CosmiconfigResult} CosmiconfigResult */
  7. /** @typedef {Promise<CosmiconfigResult | null>} ConfigPromise */
  8. /**
  9. * @param {import('stylelint').StylelintInternalApi} stylelint
  10. * @param {string} [searchPath]
  11. * @returns {ConfigPromise}
  12. */
  13. module.exports = function (stylelint, searchPath = process.cwd()) {
  14. const optionsConfig = stylelint._options.config;
  15. if (optionsConfig !== undefined) {
  16. const cached = /** @type {ConfigPromise} */ (stylelint._specifiedConfigCache.get(
  17. optionsConfig,
  18. ));
  19. if (cached) return cached;
  20. // stylelint._fullExplorer (cosmiconfig) is already configured to
  21. // run augmentConfigFull; but since we're making up the result here,
  22. // we need to manually run the transform
  23. const augmentedResult = augmentConfigFull(stylelint, {
  24. config: optionsConfig,
  25. // Add the extra path part so that we can get the directory without being
  26. // confused
  27. filepath: path.join(process.cwd(), 'argument-config'),
  28. });
  29. stylelint._specifiedConfigCache.set(optionsConfig, augmentedResult);
  30. return augmentedResult;
  31. }
  32. const searchForConfig = stylelint._options.configFile
  33. ? stylelint._fullExplorer.load(stylelint._options.configFile)
  34. : stylelint._fullExplorer.search(searchPath);
  35. return /** @type {ConfigPromise} */ (searchForConfig
  36. .then((config) => {
  37. // If no config was found, try looking from process.cwd
  38. if (!config) return stylelint._fullExplorer.search(process.cwd());
  39. return config;
  40. })
  41. .then((config) => {
  42. if (!config) {
  43. const ending = searchPath ? ` for ${searchPath}` : '';
  44. throw configurationError(`No configuration provided${ending}`);
  45. }
  46. return config;
  47. }));
  48. };