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.

hg.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.stageFile = exports.getUnstagedChangedFiles = exports.getChangedFiles = exports.getSinceRevision = exports.detect = exports.name = void 0;
  6. var _findUp = _interopRequireDefault(require("find-up"));
  7. var _execa = _interopRequireDefault(require("execa"));
  8. var _path = require("path");
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. const name = 'hg';
  11. exports.name = name;
  12. const detect = directory => {
  13. const hgDirectory = _findUp.default.sync('.hg', {
  14. cwd: directory,
  15. type: 'directory'
  16. });
  17. if (hgDirectory) {
  18. return (0, _path.dirname)(hgDirectory);
  19. }
  20. };
  21. exports.detect = detect;
  22. const runHg = (directory, args) => _execa.default.sync('hg', args, {
  23. cwd: directory
  24. });
  25. const getLines = execaResult => execaResult.stdout.split('\n');
  26. const getSinceRevision = (directory, {
  27. branch
  28. }) => {
  29. const revision = runHg(directory, ['debugancestor', 'tip', branch || 'default']).stdout.trim();
  30. return runHg(directory, ['id', '-i', '-r', revision]).stdout.trim();
  31. };
  32. exports.getSinceRevision = getSinceRevision;
  33. const getChangedFiles = (directory, revision) => {
  34. return [...getLines(runHg(directory, ['status', '-n', '-a', '-m', '--rev', revision]))].filter(Boolean);
  35. };
  36. exports.getChangedFiles = getChangedFiles;
  37. const getUnstagedChangedFiles = () => {
  38. return [];
  39. };
  40. exports.getUnstagedChangedFiles = getUnstagedChangedFiles;
  41. const stageFile = (directory, file) => {
  42. runHg(directory, ['add', file]);
  43. };
  44. exports.stageFile = stageFile;