| 
									
										
										
										
											2020-10-28 17:14:40 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google LLC All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import {Arguments, Argv, CommandModule} from 'yargs'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-30 14:53:05 -08:00
										 |  |  | import {printTargetBranchesForPr} from './check-target-branches'; | 
					
						
							| 
									
										
										
										
											2020-10-28 17:14:40 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export interface CheckTargetBranchesOptions { | 
					
						
							|  |  |  |   pr: number; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** Builds the command. */ | 
					
						
							|  |  |  | function builder(yargs: Argv) { | 
					
						
							| 
									
										
										
										
											2020-11-30 14:53:05 -08:00
										 |  |  |   return yargs.positional('pr', { | 
					
						
							|  |  |  |     description: 'The pull request number', | 
					
						
							|  |  |  |     type: 'number', | 
					
						
							|  |  |  |     demandOption: true, | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2020-10-28 17:14:40 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** Handles the command. */ | 
					
						
							| 
									
										
										
										
											2020-11-30 14:53:05 -08:00
										 |  |  | async function handler({pr}: Arguments<CheckTargetBranchesOptions>) { | 
					
						
							|  |  |  |   await printTargetBranchesForPr(pr); | 
					
						
							| 
									
										
										
										
											2020-10-28 17:14:40 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** yargs command module describing the command.  */ | 
					
						
							|  |  |  | export const CheckTargetBranchesModule: CommandModule<{}, CheckTargetBranchesOptions> = { | 
					
						
							|  |  |  |   handler, | 
					
						
							|  |  |  |   builder, | 
					
						
							|  |  |  |   command: 'check-target-branches <pr>', | 
					
						
							|  |  |  |   describe: 'Check a PR to determine what branches it is currently targeting', | 
					
						
							|  |  |  | }; |