(
program: ts.Program,
plugins: Plugin[],
emitPlan: EmitFile[],
writeFile: ts.WriteFileCallback
)
| 57 | } |
| 58 | |
| 59 | private emitFiles( |
| 60 | program: ts.Program, |
| 61 | plugins: Plugin[], |
| 62 | emitPlan: EmitFile[], |
| 63 | writeFile: ts.WriteFileCallback |
| 64 | ): ts.Diagnostic[] { |
| 65 | performance.startSection("emit"); |
| 66 | |
| 67 | const options = program.getCompilerOptions() as CompilerOptions; |
| 68 | |
| 69 | if (options.tstlVerbose) { |
| 70 | console.log("Emitting output"); |
| 71 | } |
| 72 | |
| 73 | const diagnostics: ts.Diagnostic[] = []; |
| 74 | |
| 75 | for (const plugin of plugins) { |
| 76 | if (plugin.beforeEmit) { |
| 77 | const beforeEmitPluginDiagnostics = plugin.beforeEmit(program, options, this.emitHost, emitPlan) ?? []; |
| 78 | diagnostics.push(...beforeEmitPluginDiagnostics); |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | const emitBOM = options.emitBOM ?? false; |
| 83 | for (const { outputPath, code, sourceMap, sourceFiles } of emitPlan) { |
| 84 | if (options.tstlVerbose) { |
| 85 | console.log(`Emitting ${normalizeSlashes(outputPath)}`); |
| 86 | } |
| 87 | |
| 88 | writeFile(outputPath, code, emitBOM, undefined, sourceFiles); |
| 89 | if (options.sourceMap && sourceMap !== undefined) { |
| 90 | writeFile(outputPath + ".map", sourceMap, emitBOM, undefined, sourceFiles); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | for (const plugin of plugins) { |
| 95 | if (plugin.afterEmit) { |
| 96 | const afterEmitPluginDiagnostics = plugin.afterEmit(program, options, this.emitHost, emitPlan) ?? []; |
| 97 | diagnostics.push(...afterEmitPluginDiagnostics); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | if (options.tstlVerbose) { |
| 102 | console.log("Emit finished!"); |
| 103 | } |
| 104 | |
| 105 | performance.endSection("emit"); |
| 106 | |
| 107 | return diagnostics; |
| 108 | } |
| 109 | |
| 110 | protected getEmitPlan( |
| 111 | program: ts.Program, |
no test coverage detected