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.

index.js 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _scms = _interopRequireDefault(require("./scms"));
  7. var _processFiles = _interopRequireDefault(require("./processFiles"));
  8. var _createIgnorer = _interopRequireDefault(require("./createIgnorer"));
  9. var _createMatcher = _interopRequireDefault(require("./createMatcher"));
  10. var _isSupportedExtension = _interopRequireDefault(require("./isSupportedExtension"));
  11. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  12. var _default = (currentDirectory, {
  13. config,
  14. since,
  15. staged,
  16. pattern,
  17. restage = true,
  18. branch,
  19. bail,
  20. check,
  21. ignorePath,
  22. verbose,
  23. onFoundSinceRevision,
  24. onFoundChangedFiles,
  25. onPartiallyStagedFile,
  26. onExamineFile,
  27. onCheckFile,
  28. onWriteFile,
  29. resolveConfig = true
  30. } = {}) => {
  31. const scm = (0, _scms.default)(currentDirectory);
  32. if (!scm) {
  33. throw new Error('Unable to detect a source control manager.');
  34. }
  35. const directory = scm.rootDirectory;
  36. const revision = since || scm.getSinceRevision(directory, {
  37. staged,
  38. branch
  39. });
  40. onFoundSinceRevision && onFoundSinceRevision(scm.name, revision);
  41. const rootIgnorer = (0, _createIgnorer.default)(directory, ignorePath);
  42. const cwdIgnorer = currentDirectory !== directory ? (0, _createIgnorer.default)(currentDirectory, ignorePath) : () => true;
  43. const changedFiles = scm.getChangedFiles(directory, revision, staged).filter((0, _isSupportedExtension.default)(resolveConfig)).filter((0, _createMatcher.default)(pattern)).filter(rootIgnorer).filter(cwdIgnorer);
  44. const unstagedFiles = staged ? scm.getUnstagedChangedFiles(directory, revision).filter(_isSupportedExtension.default).filter((0, _createMatcher.default)(pattern)).filter(rootIgnorer).filter(cwdIgnorer) : [];
  45. const wasFullyStaged = f => unstagedFiles.indexOf(f) < 0;
  46. onFoundChangedFiles && onFoundChangedFiles(changedFiles);
  47. const failReasons = new Set();
  48. (0, _processFiles.default)(directory, changedFiles, {
  49. check,
  50. config,
  51. onWriteFile: file => {
  52. onWriteFile && onWriteFile(file);
  53. if (bail) {
  54. failReasons.add('BAIL_ON_WRITE');
  55. }
  56. if (staged && restage) {
  57. if (wasFullyStaged(file)) {
  58. scm.stageFile(directory, file);
  59. } else {
  60. onPartiallyStagedFile && onPartiallyStagedFile(file);
  61. failReasons.add('PARTIALLY_STAGED_FILE');
  62. }
  63. }
  64. },
  65. onCheckFile: (file, isFormatted) => {
  66. onCheckFile && onCheckFile(file, isFormatted);
  67. if (!isFormatted) {
  68. failReasons.add('CHECK_FAILED');
  69. }
  70. },
  71. onExamineFile: verbose && onExamineFile
  72. });
  73. return {
  74. success: failReasons.size === 0,
  75. errors: Array.from(failReasons)
  76. };
  77. };
  78. exports.default = _default;