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.

isPathIgnored.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. const filterFilePaths = require('./utils/filterFilePaths');
  3. const getFileIgnorer = require('./utils/getFileIgnorer');
  4. const micromatch = require('micromatch');
  5. const path = require('path');
  6. const slash = require('slash');
  7. /**
  8. * To find out if a path is ignored, we need to load the config,
  9. * which may have an ignoreFiles property. We then check the path
  10. * against these.
  11. * @param {import('stylelint').StylelintInternalApi} stylelint
  12. * @param {string} [filePath]
  13. * @return {Promise<boolean>}
  14. */
  15. module.exports = function (stylelint, filePath) {
  16. if (!filePath) {
  17. return Promise.resolve(false);
  18. }
  19. const cwd = process.cwd();
  20. const ignorer = getFileIgnorer(stylelint._options);
  21. return stylelint.getConfigForFile(filePath).then((result) => {
  22. if (!result) {
  23. return true;
  24. }
  25. // Glob patterns for micromatch should be in POSIX-style
  26. const ignoreFiles = /** @type {Array<string>} */ (result.config.ignoreFiles || []).map(slash);
  27. const absoluteFilePath = path.isAbsolute(filePath)
  28. ? filePath
  29. : path.resolve(process.cwd(), filePath);
  30. if (micromatch([absoluteFilePath], ignoreFiles).length) {
  31. return true;
  32. }
  33. // Check filePath with .stylelintignore file
  34. if (filterFilePaths(ignorer, [path.relative(cwd, absoluteFilePath)]).length === 0) {
  35. return true;
  36. }
  37. return false;
  38. });
  39. };