hg.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _path() {
  7. const data = _interopRequireDefault(require('path'));
  8. _path = function _path() {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _execa() {
  14. const data = _interopRequireDefault(require('execa'));
  15. _execa = function _execa() {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _interopRequireDefault(obj) {
  21. return obj && obj.__esModule ? obj : {default: obj};
  22. }
  23. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  24. try {
  25. var info = gen[key](arg);
  26. var value = info.value;
  27. } catch (error) {
  28. reject(error);
  29. return;
  30. }
  31. if (info.done) {
  32. resolve(value);
  33. } else {
  34. Promise.resolve(value).then(_next, _throw);
  35. }
  36. }
  37. function _asyncToGenerator(fn) {
  38. return function() {
  39. var self = this,
  40. args = arguments;
  41. return new Promise(function(resolve, reject) {
  42. var gen = fn.apply(self, args);
  43. function _next(value) {
  44. asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
  45. }
  46. function _throw(err) {
  47. asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
  48. }
  49. _next(undefined);
  50. });
  51. };
  52. }
  53. function _objectSpread(target) {
  54. for (var i = 1; i < arguments.length; i++) {
  55. var source = arguments[i] != null ? arguments[i] : {};
  56. var ownKeys = Object.keys(source);
  57. if (typeof Object.getOwnPropertySymbols === 'function') {
  58. ownKeys = ownKeys.concat(
  59. Object.getOwnPropertySymbols(source).filter(function(sym) {
  60. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  61. })
  62. );
  63. }
  64. ownKeys.forEach(function(key) {
  65. _defineProperty(target, key, source[key]);
  66. });
  67. }
  68. return target;
  69. }
  70. function _defineProperty(obj, key, value) {
  71. if (key in obj) {
  72. Object.defineProperty(obj, key, {
  73. value: value,
  74. enumerable: true,
  75. configurable: true,
  76. writable: true
  77. });
  78. } else {
  79. obj[key] = value;
  80. }
  81. return obj;
  82. }
  83. const env = _objectSpread({}, process.env, {
  84. HGPLAIN: '1'
  85. });
  86. const adapter = {
  87. findChangedFiles: (function() {
  88. var _findChangedFiles = _asyncToGenerator(function*(cwd, options) {
  89. const includePaths = (options && options.includePaths) || [];
  90. const args = ['status', '-amnu'];
  91. if (options && options.withAncestor) {
  92. args.push('--rev', `min((!public() & ::.)+.)^`);
  93. } else if (options && options.changedSince) {
  94. args.push('--rev', `ancestor(., ${options.changedSince})`);
  95. } else if (options && options.lastCommit === true) {
  96. args.push('--change', '.');
  97. }
  98. args.push(...includePaths);
  99. const result = yield (0, _execa().default)('hg', args, {
  100. cwd,
  101. env
  102. });
  103. return result.stdout
  104. .split('\n')
  105. .filter(s => s !== '')
  106. .map(changedPath => _path().default.resolve(cwd, changedPath));
  107. });
  108. function findChangedFiles(_x, _x2) {
  109. return _findChangedFiles.apply(this, arguments);
  110. }
  111. return findChangedFiles;
  112. })(),
  113. getRoot: (function() {
  114. var _getRoot = _asyncToGenerator(function*(cwd) {
  115. try {
  116. const result = yield (0, _execa().default)('hg', ['root'], {
  117. cwd,
  118. env
  119. });
  120. return result.stdout;
  121. } catch (e) {
  122. return null;
  123. }
  124. });
  125. function getRoot(_x3) {
  126. return _getRoot.apply(this, arguments);
  127. }
  128. return getRoot;
  129. })()
  130. };
  131. var _default = adapter;
  132. exports.default = _default;