@@ -44,8 +44,9 @@ const TEMP_DIR = TEMP.name;
4444const TEMP_DOWNSTREAM_CACHE = path . resolve ( TEMP_DIR , '.downstream_cache' ) ;
4545const 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
7273function 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