How to use the broccoli.Watcher function in broccoli

To help you get started, we’ve selected a few broccoli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github denali-js / core / lib / cli / broccoli / denali-app.js View on Github external
build() {
    let tree = this.toTree();
    if (!fs.existsSync('tmp')) {
      fs.mkdirSync('tmp');
    }
    let builder = new broccoli.Builder(tree, { tmpdir: './tmp' });
    if (this.watch) {
      let watcher = new broccoli.Watcher(builder);
      watcher.on('change', () => {
        try {
          let duration = Math.round(builder.outputNodeWrapper.buildState.totalTime) + 'ms';
          if (duration > 1000) {
            duration = chalk.yellow(duration);
          }
          log('info', `${ this.firstBuild ? 'Build' : 'Rebuild' } complete (${ duration })`);
          this.afterBuild(builder.outputPath);
          this.firstBuild = false;
          if (duration > 1000) {
            printSlowNodes(builder.outputNodeWrapper);
          }
        } catch (err) {
          console.log('Error while attempting to restart the server:\n', err.stack || err);
        }
      });
github cliqz-oss / browser-core / fern / common.js View on Github external
function getBroccoliWatcher(outputDir, builder, ui) {
  return new broccoli.Watcher(
    builder,
    builder.watchedSourceNodeWrappers,
    buildWatcherOptions(ui),
  );
}
github ember-cli / ember-cli / lib / models / watcher.js View on Github external
constructBroccoliWatcher(options) {
    const { Watcher } = require('broccoli');
    const { watchedSourceNodeWrappers } = this.builder.builder;

    let watcher = new Watcher(this.builder, watchedSourceNodeWrappers, { saneOptions: options });

    watcher.start();

    return watcher;
  }