@@ -44,8 +44,9 @@ const TEMP_DIR = TEMP.name;
44
44
const TEMP_DOWNSTREAM_CACHE = path . resolve ( TEMP_DIR , '.downstream_cache' ) ;
45
45
const DOWNSTREAM_CACHE = path . resolve ( PKG_DIR , '.downstream_cache' ) ;
46
46
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 ( ) ) ;
49
50
const configBlock = _ . toPairs ( config . projects || config ) ;
50
51
51
52
// Object values are groups (nested config). string values are github url or local file path
@@ -58,7 +59,7 @@ function parseConfig() {
58
59
const groups = _ . fromPairs ( groupsAsPairs ) ;
59
60
groups . all = _ . fromPairs ( allGroupedProjectPairs . concat ( ungroupedProjectsAsPairs ) ) ;
60
61
61
- const projects = groups [ yargs . argv . group ] ;
62
+ const projects = groups [ limitToGroup ] ;
62
63
if ( ! projects ) {
63
64
throw new Error ( `Attempting to run tests for a group named ${ yargs . argv . group } , but no matching group was found in downstream_projects.json` ) ;
64
65
}
@@ -67,7 +68,7 @@ function parseConfig() {
67
68
return { projects, nohoist } ;
68
69
}
69
70
70
- const { projects, nohoist } = parseConfig ( ) ;
71
+ const { projects, nohoist } = parseConfig ( 'downstream_projects.json' , yargs . argv . group ) ;
71
72
72
73
function makeDownstreamCache ( ) {
73
74
if ( ! fs . existsSync ( DOWNSTREAM_CACHE ) ) {
@@ -167,8 +168,9 @@ function fetchDownstreamProjects(downstreamConfig, prefix, downstreamTreeNode) {
167
168
168
169
const nestedDownstreamConfigPath = path . resolve ( DOWNSTREAM_CACHE , installDir , 'downstream_projects.json' ) ;
169
170
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 ) ;
172
174
}
173
175
} ) ;
174
176
}
0 commit comments