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.

git.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function path() {
  7. const data = _interopRequireWildcard(require('path'));
  8. path = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _execa() {
  14. const data = _interopRequireDefault(require('execa'));
  15. _execa = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _interopRequireDefault(obj) {
  21. return obj && obj.__esModule ? obj : {default: obj};
  22. }
  23. function _getRequireWildcardCache(nodeInterop) {
  24. if (typeof WeakMap !== 'function') return null;
  25. var cacheBabelInterop = new WeakMap();
  26. var cacheNodeInterop = new WeakMap();
  27. return (_getRequireWildcardCache = function (nodeInterop) {
  28. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  29. })(nodeInterop);
  30. }
  31. function _interopRequireWildcard(obj, nodeInterop) {
  32. if (!nodeInterop && obj && obj.__esModule) {
  33. return obj;
  34. }
  35. if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
  36. return {default: obj};
  37. }
  38. var cache = _getRequireWildcardCache(nodeInterop);
  39. if (cache && cache.has(obj)) {
  40. return cache.get(obj);
  41. }
  42. var newObj = {};
  43. var hasPropertyDescriptor =
  44. Object.defineProperty && Object.getOwnPropertyDescriptor;
  45. for (var key in obj) {
  46. if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
  47. var desc = hasPropertyDescriptor
  48. ? Object.getOwnPropertyDescriptor(obj, key)
  49. : null;
  50. if (desc && (desc.get || desc.set)) {
  51. Object.defineProperty(newObj, key, desc);
  52. } else {
  53. newObj[key] = obj[key];
  54. }
  55. }
  56. }
  57. newObj.default = obj;
  58. if (cache) {
  59. cache.set(obj, newObj);
  60. }
  61. return newObj;
  62. }
  63. /**
  64. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  65. *
  66. * This source code is licensed under the MIT license found in the
  67. * LICENSE file in the root directory of this source tree.
  68. *
  69. */
  70. const findChangedFilesUsingCommand = async (args, cwd) => {
  71. let result;
  72. try {
  73. result = await (0, _execa().default)('git', args, {
  74. cwd
  75. });
  76. } catch (e) {
  77. // TODO: Should we keep the original `message`?
  78. e.message = e.stderr;
  79. throw e;
  80. }
  81. return result.stdout
  82. .split('\n')
  83. .filter(s => s !== '')
  84. .map(changedPath => path().resolve(cwd, changedPath));
  85. };
  86. const adapter = {
  87. findChangedFiles: async (cwd, options) => {
  88. const changedSince =
  89. options && (options.withAncestor ? 'HEAD^' : options.changedSince);
  90. const includePaths = ((options && options.includePaths) || []).map(
  91. absoluteRoot => path().normalize(path().relative(cwd, absoluteRoot))
  92. );
  93. if (options && options.lastCommit) {
  94. return findChangedFilesUsingCommand(
  95. ['show', '--name-only', '--pretty=format:', 'HEAD', '--'].concat(
  96. includePaths
  97. ),
  98. cwd
  99. );
  100. }
  101. if (changedSince) {
  102. const [committed, staged, unstaged] = await Promise.all([
  103. findChangedFilesUsingCommand(
  104. ['diff', '--name-only', `${changedSince}...HEAD`, '--'].concat(
  105. includePaths
  106. ),
  107. cwd
  108. ),
  109. findChangedFilesUsingCommand(
  110. ['diff', '--cached', '--name-only', '--'].concat(includePaths),
  111. cwd
  112. ),
  113. findChangedFilesUsingCommand(
  114. [
  115. 'ls-files',
  116. '--other',
  117. '--modified',
  118. '--exclude-standard',
  119. '--'
  120. ].concat(includePaths),
  121. cwd
  122. )
  123. ]);
  124. return [...committed, ...staged, ...unstaged];
  125. }
  126. const [staged, unstaged] = await Promise.all([
  127. findChangedFilesUsingCommand(
  128. ['diff', '--cached', '--name-only', '--'].concat(includePaths),
  129. cwd
  130. ),
  131. findChangedFilesUsingCommand(
  132. [
  133. 'ls-files',
  134. '--other',
  135. '--modified',
  136. '--exclude-standard',
  137. '--'
  138. ].concat(includePaths),
  139. cwd
  140. )
  141. ]);
  142. return [...staged, ...unstaged];
  143. },
  144. getRoot: async cwd => {
  145. const options = ['rev-parse', '--show-cdup'];
  146. try {
  147. const result = await (0, _execa().default)('git', options, {
  148. cwd
  149. });
  150. return path().resolve(cwd, result.stdout);
  151. } catch {
  152. return null;
  153. }
  154. }
  155. };
  156. var _default = adapter;
  157. exports.default = _default;