getChangedFilesPromise.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = getChangedFilesPromise;
  6. function _chalk() {
  7. const data = _interopRequireDefault(require('chalk'));
  8. _chalk = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _jestChangedFiles() {
  14. const data = require('jest-changed-files');
  15. _jestChangedFiles = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _jestMessageUtil() {
  21. const data = require('jest-message-util');
  22. _jestMessageUtil = function () {
  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. function getChangedFilesPromise(globalConfig, configs) {
  37. if (globalConfig.onlyChanged) {
  38. const allRootsForAllProjects = configs.reduce((roots, config) => {
  39. if (config.roots) {
  40. roots.push(...config.roots);
  41. }
  42. return roots;
  43. }, []);
  44. return (0, _jestChangedFiles().getChangedFilesForRoots)(
  45. allRootsForAllProjects,
  46. {
  47. changedSince: globalConfig.changedSince,
  48. lastCommit: globalConfig.lastCommit,
  49. withAncestor: globalConfig.changedFilesWithAncestor
  50. }
  51. ).catch(e => {
  52. const message = (0, _jestMessageUtil().formatExecError)(e, configs[0], {
  53. noStackTrace: true
  54. })
  55. .split('\n')
  56. .filter(line => !line.includes('Command failed:'))
  57. .join('\n');
  58. console.error(_chalk().default.red(`\n\n${message}`));
  59. process.exit(1);
  60. });
  61. }
  62. return undefined;
  63. }