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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.findRepos = exports.getChangedFilesForRoots = void 0;
  6. function _throat() {
  7. const data = _interopRequireDefault(require('throat'));
  8. _throat = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. var _git = _interopRequireDefault(require('./git'));
  14. var _hg = _interopRequireDefault(require('./hg'));
  15. function _interopRequireDefault(obj) {
  16. return obj && obj.__esModule ? obj : {default: obj};
  17. }
  18. /**
  19. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  20. *
  21. * This source code is licensed under the MIT license found in the
  22. * LICENSE file in the root directory of this source tree.
  23. *
  24. */
  25. function notEmpty(value) {
  26. return value != null;
  27. } // This is an arbitrary number. The main goal is to prevent projects with
  28. // many roots (50+) from spawning too many processes at once.
  29. const mutex = (0, _throat().default)(5);
  30. const findGitRoot = dir => mutex(() => _git.default.getRoot(dir));
  31. const findHgRoot = dir => mutex(() => _hg.default.getRoot(dir));
  32. const getChangedFilesForRoots = async (roots, options) => {
  33. const repos = await findRepos(roots);
  34. const changedFilesOptions = {
  35. includePaths: roots,
  36. ...options
  37. };
  38. const gitPromises = Array.from(repos.git).map(repo =>
  39. _git.default.findChangedFiles(repo, changedFilesOptions)
  40. );
  41. const hgPromises = Array.from(repos.hg).map(repo =>
  42. _hg.default.findChangedFiles(repo, changedFilesOptions)
  43. );
  44. const changedFiles = (
  45. await Promise.all(gitPromises.concat(hgPromises))
  46. ).reduce((allFiles, changedFilesInTheRepo) => {
  47. for (const file of changedFilesInTheRepo) {
  48. allFiles.add(file);
  49. }
  50. return allFiles;
  51. }, new Set());
  52. return {
  53. changedFiles,
  54. repos
  55. };
  56. };
  57. exports.getChangedFilesForRoots = getChangedFilesForRoots;
  58. const findRepos = async roots => {
  59. const gitRepos = await Promise.all(
  60. roots.reduce((promises, root) => promises.concat(findGitRoot(root)), [])
  61. );
  62. const hgRepos = await Promise.all(
  63. roots.reduce((promises, root) => promises.concat(findHgRoot(root)), [])
  64. );
  65. return {
  66. git: new Set(gitRepos.filter(notEmpty)),
  67. hg: new Set(hgRepos.filter(notEmpty))
  68. };
  69. };
  70. exports.findRepos = findRepos;