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.

getFileIgnorer.js 998B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. // Try to get file ignorer from '.stylelintignore'
  3. const fs = require('fs');
  4. const path = require('path');
  5. const { default: ignore } = require('ignore');
  6. const DEFAULT_IGNORE_FILENAME = '.stylelintignore';
  7. const FILE_NOT_FOUND_ERROR_CODE = 'ENOENT';
  8. /** @typedef {import('stylelint').StylelintStandaloneOptions} StylelintOptions */
  9. /**
  10. * @param {StylelintOptions} options
  11. * @return {import('ignore').Ignore}
  12. */
  13. module.exports = function (options) {
  14. const ignoreFilePath = options.ignorePath || DEFAULT_IGNORE_FILENAME;
  15. const absoluteIgnoreFilePath = path.isAbsolute(ignoreFilePath)
  16. ? ignoreFilePath
  17. : path.resolve(process.cwd(), ignoreFilePath);
  18. let ignoreText = '';
  19. try {
  20. ignoreText = fs.readFileSync(absoluteIgnoreFilePath, 'utf8');
  21. } catch (readError) {
  22. if (readError.code !== FILE_NOT_FOUND_ERROR_CODE) throw readError;
  23. }
  24. const ignorePattern = options.ignorePattern || [];
  25. const ignorer = ignore().add(ignoreText).add(ignorePattern);
  26. return ignorer;
  27. };