UNPKG

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