<commit_before>var Output = require('systemjs-builder/lib/output'),
  Writer = require('broccoli-writer'),
  RSVP = require('rsvp'),
  path = require('path'),
  fs = require('fs');
  paths = {};

var writeOutputs = Output.writeOutputs;

Output.writeOutputs = function( outputs, baseURL, outputOpts ) {
  baseURL = baseURL.replace(paths.sourceDir, paths.destDir);

  if (outputOpts.outFile) {
    outputOpts.outFile = path.join(paths.destDir, outputOpts.outFile);
  }

  return writeOutputs.apply(this, arguments);
};

var Builder = require('systemjs-builder');

function SystemBuilder ( inputNodes, baseURL, configPath, fn ) {
  if (!(this instanceof SystemBuilder)) {
    return new SystemBuilder(inputNodes, baseURL, configPath, fn);
  }

  this.buildCount = 0;
  this.builder = new Builder();
  this.inputNodes = inputNodes;
  this.baseURL = baseURL;
  this.configPath = configPath;
  this.fn = fn;
};

SystemBuilder.prototype = Object.create(Writer.prototype);
SystemBuilder.prototype.constructor = SystemBuilder;

SystemBuilder.prototype.write = function( readTree, destDir ) {
  return readTree(this.inputNodes).then(function( sourceDir ) {
    var configPath = path.join(sourceDir, this.configPath),
      baseURL = path.join(sourceDir, this.baseURL),
      builder = this.builder,
      fn = this.fn;

    paths.sourceDir = sourceDir;
    paths.destDir = destDir;


    if (this.buildCount++ === 0) {
      builder.config({
        baseURL: baseURL
      }, true, false);

      builder.loadConfigSync(configPath, true, true);
    }

    return new RSVP.Promise(function( resolve ) {
      resolve();
    }).then(function() {
      return fn(builder, sourceDir, destDir);
    });
  }.bind(this));
};

module.exports = SystemBuilder;<commit_msg>Do partial cache invalidation before rebuilds<commit_after>var Output = require('systemjs-builder/lib/output'),
  Writer = require('broccoli-writer'),
  RSVP = require('rsvp'),
  path = require('path'),
  fs = require('fs');
  paths = {};

var writeOutputs = Output.writeOutputs;

Output.writeOutputs = function( outputs, baseURL, outputOpts ) {
  baseURL = baseURL.replace(paths.sourceDir, paths.destDir);

  if (outputOpts.outFile) {
    outputOpts.outFile = path.join(paths.destDir, outputOpts.outFile);
  }

  return writeOutputs.apply(this, arguments);
};

var Builder = require('systemjs-builder');

function SystemBuilder ( inputNodes, baseURL, configPath, fn ) {
  if (!(this instanceof SystemBuilder)) {
    return new SystemBuilder(inputNodes, baseURL, configPath, fn);
  }

  this.buildCount = 0;
  this.builder = new Builder();
  this.inputNodes = inputNodes;
  this.baseURL = baseURL;
  this.configPath = configPath;
  this.fn = fn;
};

SystemBuilder.prototype = Object.create(Writer.prototype);
SystemBuilder.prototype.constructor = SystemBuilder;

SystemBuilder.prototype.write = function( readTree, destDir ) {
  return readTree(this.inputNodes).then(function( sourceDir ) {
    var configPath = path.join(sourceDir, this.configPath),
      baseURL = path.join(sourceDir, this.baseURL),
      builder = this.builder,
      fn = this.fn;

    paths.sourceDir = sourceDir;
    paths.destDir = destDir;


    if (this.buildCount++ === 0) {
      builder.config({
        baseURL: baseURL
      }, true, false);

      builder.loadConfigSync(configPath, true, true);
    } else {
      builder.invalidate('*');
    }

    return new RSVP.Promise(function( resolve ) {
      resolve();
    }).then(function() {
      return fn(builder, sourceDir, destDir);
    });
  }.bind(this));
};

module.exports = SystemBuilder;
{'fraction_non_alphanumeric': 0.13603351955307263, 'fraction_numerical': 0.0011173184357541898, 'mean_word_length': 3.84573748308525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3759578', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1092, 'n_words': 232}