const path = require('path');
const { Builder, ui } = require(`denali-cli`);
const { exec } = require('child_process');
const Funnel = require('broccoli-funnel');
const MergeTree = require('broccoli-merge-trees');
const { typescript: Typescript } = require('broccoli-typescript-compiler');

module.exports = class DenaliBuilder extends Builder {

  processSelf(tree, dir) {
    tree = this.transpileTree(tree, dir);
    return tree;
  }

  transpileTree(tree, dir) {
    let transpiledTS = new Typescript(tree, {
      tsconfig: require(path.join(dir, 'tsconfig.json')),
      annotation: 'compile typescript'
    });
    let withoutTS = new Funnel(tree, {
      exclude: [ '**/*.ts' ]
    });
    return new MergeTree([ withoutTS, transpiledTS ], { overwrite: true, annotation: 'merge typescript output' });
  }

};

@@ -19,24 +19,56 @@
 re('path');%0A
+const chalk = require('chalk');%0A
 const %7B Buil
@@ -639,24 +639,183 @@
 pt'%0A    %7D);%0A
+    transpiledTS.setDiagnosticWriter((message) =%3E %7B%0A      ui.warn(chalk.bold(%60==%3E %5Bdenali%5D Typescript compilation errors: %60));%0A      ui.warn(message);%0A    %7D);%0A
     let with

improve typescript error output formatting when building denali itself