()
| 556 | } |
| 557 | |
| 558 | write(): Promise<unknown> { |
| 559 | return this.span.traceChildAsync('write all', async (childSpan) => { |
| 560 | await childSpan.traceChildAsync('done', () => this.done()); |
| 561 | |
| 562 | childSpan.traceChildSync('write to strategies', () => this.writeToStrategies()); |
| 563 | |
| 564 | return childSpan.traceChildAsync('output to disk', (childSpan) => { |
| 565 | const promises: Array<Promise<void>> = []; |
| 566 | |
| 567 | const descriptions = nullthrow(this.description, 'Missing description'); |
| 568 | |
| 569 | if (this.dataSource.size) { |
| 570 | descriptions.push( |
| 571 | '', |
| 572 | 'This file contains data from:' |
| 573 | ); |
| 574 | appendArrayInPlace(descriptions, Array.from(this.dataSource).sort().map((source) => ` - ${source}`)); |
| 575 | } |
| 576 | |
| 577 | for (let i = 0, len = this.strategies.length; i < len; i++) { |
| 578 | const strategy = this.strategies[i]; |
| 579 | |
| 580 | const basename = (strategy.overwriteFilename || this.id) + '.' + strategy.fileExtension; |
| 581 | |
| 582 | promises.push( |
| 583 | childSpan.traceChildAsync('write ' + strategy.name, (childSpan) => Promise.resolve(strategy.output( |
| 584 | childSpan, |
| 585 | nullthrow(this.title, 'Missing title'), |
| 586 | descriptions, |
| 587 | this.date, |
| 588 | path.join( |
| 589 | strategy.outputDir, |
| 590 | strategy.type |
| 591 | ? path.join(strategy.type, basename) |
| 592 | : basename |
| 593 | ) |
| 594 | ))) |
| 595 | ); |
| 596 | } |
| 597 | |
| 598 | return Promise.all(promises); |
| 599 | }); |
| 600 | }); |
| 601 | } |
| 602 | |
| 603 | async compile(): Promise<Array<string[] | null>> { |
| 604 | await this.done(); |
no test coverage detected