forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getProjectsRunningMessage.ts
34 lines (31 loc) · 1.02 KB
/
getProjectsRunningMessage.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {Config} from '@jest/types';
import getProjectDisplayName from './getProjectDisplayName';
export default function getProjectsRunningMessage(
projectConfigs: Array<Config.ProjectConfig>,
): string {
if (projectConfigs.length === 0) {
return 'No project to run';
}
if (projectConfigs.length === 1) {
const name = getProjectDisplayName(projectConfigs[0]);
return `Running one project: ${name}`;
}
const projectsList = projectConfigs
.map(getProjectNameListElement)
.sort()
.join('\n');
return `Running ${projectConfigs.length} projects:\n` + projectsList;
}
function getProjectNameListElement(
projectConfig: Config.ProjectConfig,
): string {
const name = getProjectDisplayName(projectConfig);
const elementContent = name || '<unnamed project>';
return `- ${elementContent}`;
}