getChangedFilesPromise.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _jestChangedFiles() {
  7. const data = require('jest-changed-files');
  8. _jestChangedFiles = function _jestChangedFiles() {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _jestMessageUtil() {
  14. const data = require('jest-message-util');
  15. _jestMessageUtil = function _jestMessageUtil() {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _chalk() {
  21. const data = _interopRequireDefault(require('chalk'));
  22. _chalk = function _chalk() {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _interopRequireDefault(obj) {
  28. return obj && obj.__esModule ? obj : {default: obj};
  29. }
  30. /**
  31. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  32. *
  33. * This source code is licensed under the MIT license found in the
  34. * LICENSE file in the root directory of this source tree.
  35. */
  36. var _default = (globalConfig, configs) => {
  37. if (globalConfig.onlyChanged) {
  38. const allRootsForAllProjects = configs.reduce(
  39. (roots, config) => [...roots, ...(config.roots || [])],
  40. []
  41. );
  42. return (0, _jestChangedFiles().getChangedFilesForRoots)(
  43. allRootsForAllProjects,
  44. {
  45. changedSince: globalConfig.changedSince,
  46. lastCommit: globalConfig.lastCommit,
  47. withAncestor: globalConfig.changedFilesWithAncestor
  48. }
  49. ).catch(e => {
  50. const message = (0, _jestMessageUtil().formatExecError)(e, configs[0], {
  51. noStackTrace: true
  52. })
  53. .split('\n')
  54. .filter(line => !line.includes('Command failed:'))
  55. .join('\n');
  56. console.error(_chalk().default.red(`\n\n${message}`));
  57. process.exit(1); // We do process.exit, so this is dead code
  58. return Promise.reject(e);
  59. });
  60. }
  61. return undefined;
  62. };
  63. exports.default = _default;