(fileName: string, className: string)
| 368 | } |
| 369 | |
| 370 | driveHmr(fileName: string, className: string): string | null { |
| 371 | const {rootNames, options} = readNgcCommandLineAndConfiguration(this.commandLineArgs); |
| 372 | const host = createCompilerHost({options}); |
| 373 | const program = createProgram({rootNames, host, options}); |
| 374 | const sourceFile = program.getTsProgram().getSourceFile(fileName); |
| 375 | |
| 376 | if (sourceFile == null) { |
| 377 | throw new Error(`Cannot find file at "${fileName}"`); |
| 378 | } |
| 379 | |
| 380 | for (const node of sourceFile.statements) { |
| 381 | if (ts.isClassDeclaration(node) && node.name != null && node.name.text === className) { |
| 382 | return (program as NgtscProgram).compiler.emitHmrUpdateModule(node); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | throw new Error(`Cannot find class with name "${className}" in "${fileName}"`); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | class AugmentedCompilerHost extends NgtscTestCompilerHost { |
no test coverage detected