UNPKG

1.17 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true
5});
6exports.default = getConfigsOfProjectsToRun;
7var _getProjectDisplayName = _interopRequireDefault(
8 require('./getProjectDisplayName')
9);
10function _interopRequireDefault(obj) {
11 return obj && obj.__esModule ? obj : {default: obj};
12}
13/**
14 * Copyright (c) Meta Platforms, Inc. and affiliates.
15 *
16 * This source code is licensed under the MIT license found in the
17 * LICENSE file in the root directory of this source tree.
18 */
19
20function getConfigsOfProjectsToRun(projectConfigs, opts) {
21 const projectFilter = createProjectFilter(opts);
22 return projectConfigs.filter(config => {
23 const name = (0, _getProjectDisplayName.default)(config);
24 return projectFilter(name);
25 });
26}
27function createProjectFilter(opts) {
28 const {selectProjects, ignoreProjects} = opts;
29 const always = () => true;
30 const selected = selectProjects
31 ? name => name && selectProjects.includes(name)
32 : always;
33 const notIgnore = ignoreProjects
34 ? name => !(name && ignoreProjects.includes(name))
35 : always;
36 function test(name) {
37 return selected(name) && notIgnore(name);
38 }
39 return test;
40}