Skip to content

Commit 4aeac16

Browse files
fix(test_downstream_projects): When supplying --group to test_downstream_projects, only apply the --group to the top level project. However, parse all downstream_projects.json with group support.
1 parent 1c8680f commit 4aeac16

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test_downstream_projects.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ const TEMP_DIR = TEMP.name;
4444
const TEMP_DOWNSTREAM_CACHE = path.resolve(TEMP_DIR, '.downstream_cache');
4545
const DOWNSTREAM_CACHE = path.resolve(PKG_DIR, '.downstream_cache');
4646

47-
function parseConfig() {
48-
const config = JSON.parse(fs.readFileSync('downstream_projects.json'));
47+
function parseConfig(configFilePath, limitToGroup = 'all') {
48+
console.log('parsing config for ' + configFilePath);
49+
const config = JSON.parse(fs.readFileSync(configFilePath).toString());
4950
const configBlock = _.toPairs(config.projects || config);
5051

5152
// Object values are groups (nested config). string values are github url or local file path
@@ -58,7 +59,7 @@ function parseConfig() {
5859
const groups = _.fromPairs(groupsAsPairs);
5960
groups.all = _.fromPairs(allGroupedProjectPairs.concat(ungroupedProjectsAsPairs));
6061

61-
const projects = groups[yargs.argv.group];
62+
const projects = groups[limitToGroup];
6263
if (!projects) {
6364
throw new Error(`Attempting to run tests for a group named ${yargs.argv.group}, but no matching group was found in downstream_projects.json`);
6465
}
@@ -67,7 +68,7 @@ function parseConfig() {
6768
return { projects, nohoist };
6869
}
6970

70-
const { projects, nohoist } = parseConfig();
71+
const { projects, nohoist } = parseConfig('downstream_projects.json', yargs.argv.group);
7172

7273
function makeDownstreamCache() {
7374
if (!fs.existsSync(DOWNSTREAM_CACHE)) {
@@ -167,8 +168,9 @@ function fetchDownstreamProjects(downstreamConfig, prefix, downstreamTreeNode) {
167168

168169
const nestedDownstreamConfigPath = path.resolve(DOWNSTREAM_CACHE, installDir, 'downstream_projects.json');
169170
if (fs.existsSync(nestedDownstreamConfigPath)) {
170-
const nestedDownstreamConfig = JSON.parse(fs.readFileSync(nestedDownstreamConfigPath));
171-
fetchDownstreamProjects(nestedDownstreamConfig.projects || nestedDownstreamConfig, installDir, children);
171+
const { projects } = parseConfig(nestedDownstreamConfigPath);
172+
console.log({ projects });
173+
fetchDownstreamProjects(projects, installDir, children);
172174
}
173175
});
174176
}

0 commit comments

Comments
 (0)