| 
									
										
										
										
											2017-07-21 14:20:34 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. 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
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-02 11:20:07 -07:00
										 |  |  | // TODO(chuckj): Remove the requirement for a fake 'reflect` implementation from
 | 
					
						
							| 
									
										
										
										
											2017-07-21 14:20:34 -07:00
										 |  |  | // the compiler
 | 
					
						
							|  |  |  | import 'reflect-metadata'; | 
					
						
							| 
									
										
										
										
											2017-08-09 13:45:45 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | import {calcProjectFileAndBasePath, createNgCompilerOptions, formatDiagnostics, performCompilation} from '@angular/compiler-cli'; | 
					
						
							| 
									
										
										
										
											2017-07-21 14:20:34 -07:00
										 |  |  | import * as fs from 'fs'; | 
					
						
							| 
									
										
										
										
											2017-07-26 11:40:33 -05:00
										 |  |  | import * as path from 'path'; | 
					
						
							| 
									
										
										
										
											2017-07-21 14:20:34 -07:00
										 |  |  | // Note, the tsc_wrapped module comes from rules_typescript, not from @angular/tsc-wrapped
 | 
					
						
							|  |  |  | import {parseTsconfig} from 'tsc_wrapped'; | 
					
						
							| 
									
										
										
										
											2017-08-09 13:45:45 -07:00
										 |  |  | import * as ts from 'typescript'; | 
					
						
							| 
									
										
										
										
											2017-07-21 14:20:34 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | function main(args: string[]) { | 
					
						
							| 
									
										
										
										
											2017-08-09 13:45:45 -07:00
										 |  |  |   const project = args[1]; | 
					
						
							|  |  |  |   const [{options: tsOptions, bazelOpts, files, config}] = parseTsconfig(project); | 
					
						
							|  |  |  |   const {basePath} = calcProjectFileAndBasePath(project); | 
					
						
							|  |  |  |   const ngOptions = createNgCompilerOptions(basePath, config, tsOptions); | 
					
						
							| 
									
										
										
										
											2017-07-21 14:20:34 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-09 13:45:45 -07:00
										 |  |  |   const {diagnostics} = performCompilation(files, ngOptions); | 
					
						
							|  |  |  |   if (diagnostics.length) { | 
					
						
							|  |  |  |     console.error(formatDiagnostics(ngOptions, diagnostics)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return diagnostics.some(d => d.category === ts.DiagnosticCategory.Error) ? 1 : 0; | 
					
						
							| 
									
										
										
										
											2017-07-21 14:20:34 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (require.main === module) { | 
					
						
							|  |  |  |   process.exitCode = main(process.argv.slice(2)); | 
					
						
							| 
									
										
										
										
											2017-07-26 11:40:33 -05:00
										 |  |  | } |