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.

processFiles.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _fs = require("fs");
  7. var prettier = _interopRequireWildcard(require("prettier"));
  8. var _path = require("path");
  9. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
  10. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  11. var _default = (directory, files, {
  12. check,
  13. config,
  14. onExamineFile,
  15. onCheckFile,
  16. onWriteFile
  17. } = {}) => {
  18. for (const relative of files) {
  19. onExamineFile && onExamineFile(relative);
  20. const file = (0, _path.join)(directory, relative);
  21. const options = Object.assign({}, prettier.resolveConfig.sync(file, {
  22. config,
  23. editorconfig: true
  24. }), {
  25. filepath: file
  26. });
  27. const input = (0, _fs.readFileSync)(file, 'utf8');
  28. if (check) {
  29. const isFormatted = prettier.check(input, options);
  30. onCheckFile && onCheckFile(relative, isFormatted);
  31. continue;
  32. }
  33. const output = prettier.format(input, options);
  34. if (output !== input) {
  35. (0, _fs.writeFileSync)(file, output);
  36. onWriteFile && onWriteFile(relative);
  37. }
  38. }
  39. };
  40. exports.default = _default;