File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed
Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -16,17 +16,13 @@ async function main(args: string[]) {
1616 . flat ( ) ;
1717
1818 const startIndex = projects . indexOf ( startProject ) ;
19- const filteredProjects = projects . slice ( startIndex ) ;
19+ if ( startIndex === - 1 ) {
20+ console . error ( `Project ${ startProject } not found` ) ;
21+ process . exit ( 1 ) ;
22+ }
2023
21- const pairwisedProjects = filteredProjects . reduce (
22- ( acc , project , index ) => {
23- if ( index > 0 ) {
24- acc . push ( [ projects [ index - 1 ] , project ] ) ;
25- }
26- return acc ;
27- } ,
28- [ ] as [ string , string ] [ ] ,
29- ) ;
24+ const filteredProjects = projects . slice ( startIndex ) ;
25+ const pairwisedProjects = pairwise ( filteredProjects ) ;
3026
3127 for ( const [ source , destination ] of pairwisedProjects ) {
3228 execSync ( `pnpm nx run tools:clone-changes ${ source } ${ destination } ` , {
@@ -42,4 +38,16 @@ function computeExerciseProjects(exerciseId: string) {
4238 } ;
4339}
4440
41+ function pairwise < T > ( list : Array < T > ) : Array < [ T , T ] > {
42+ return list . reduce (
43+ ( acc , project , index ) => {
44+ if ( index > 0 ) {
45+ acc . push ( [ list [ index - 1 ] , project ] ) ;
46+ }
47+ return acc ;
48+ } ,
49+ [ ] as [ T , T ] [ ] ,
50+ ) ;
51+ }
52+
4553main ( process . argv . slice ( 2 ) ) ;
You can’t perform that action at this time.
0 commit comments