<commit_before>// RockUp
// Builder -- Build and bundle meteor applications and package for deployment

var _ = require("underscore");
var spawn = require("child_process").spawn;
var path = require("path");
var fs = require("fs");
var inspect = require("util").inspect;
var archiver = require("archiver");

module.exports = Builder;

function Builder (appDir, targetDir) {
  this.appDir = appDir;
  this.targetDir = targetDir;
  this.archivePath = path.resolve(this.targetDir, "bundle.tar.gz");
  console.log("Builder instantiated:", inspect(this, {colors:true}));
}

Builder.prototype.buildAndZip = function (callbackFn) {
  var self = this;
  self.build( function() {
    self.zip( callbackFn );
  });
};

Builder.prototype.build = function (callbackFn) {
  console.log("Building application bundle...");
  var args = ["build", "--directory", this.targetDir, "--server", "http://localhost:3000"];
  var meteor = spawn("meteor", args, {cwd: this.appDir, stdio: [process.stdin, process.stdout, process.stderr] });
  meteor.on('close', callbackFn);
};

Builder.prototype.zip = function (callbackFn) {
  console.log("Archiving application bundle...");
  var srcDir = this.targetDir;
  var tgtPath = this.archivePath;

  var output = fs.createWriteStream(tgtPath);
  var archive = archiver("tar", {
    gzip: true,
    gzipOptions: { level: 9 }
  });
  archive.pipe(output);
  output.once("close", callbackFn);
  archive.once("error", function(err) {
    console.error("Bundle archiving failed:", err);
    callbackFn(err);
  });

  archive.directory(srcDir, "bundle").finalize();
};<commit_msg>buildDir is a cleaner name for this<commit_after>// RockUp
// Builder -- Build and bundle meteor applications and package for deployment

var _ = require("underscore");
var spawn = require("child_process").spawn;
var path = require("path");
var fs = require("fs");
var inspect = require("util").inspect;
var archiver = require("archiver");

module.exports = Builder;

function Builder (appDir, buildDir) {
  this.appDir = appDir;
  this.buildDir = buildDir;
  this.archivePath = path.resolve(this.buildDir, "bundle.tar.gz");
}

Builder.prototype.buildAndZip = function (callbackFn) {
  var self = this;
  self.build( function() {
    self.zip( callbackFn );
  });
};

Builder.prototype.build = function (callbackFn) {
  console.log("Building application bundle...");
  var args = ["build", "--directory", this.buildDir, "--server", "http://localhost:3000"];
  var meteor = spawn("meteor", args, {cwd: this.appDir, stdio: [process.stdin, process.stdout, process.stderr] });
  meteor.on('close', callbackFn);
};

Builder.prototype.zip = function (callbackFn) {
  console.log("Archiving application bundle...");
  var srcDir = this.buildDir;
  var tgtPath = this.archivePath;

  var output = fs.createWriteStream(tgtPath);
  var archive = archiver("tar", {
    gzip: true,
    gzipOptions: { level: 9 }
  });
  archive.pipe(output);
  output.once("close", callbackFn);
  archive.once("error", function(err) {
    console.error("Bundle archiving failed:", err);
    callbackFn(err);
  });

  archive.directory(srcDir, "bundle").finalize();
};
{'fraction_non_alphanumeric': 0.16485623003194888, 'fraction_numerical': 0.003194888178913738, 'mean_word_length': 4.551418439716312, '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': '6460214', 'n_tokens_mistral': 994, 'n_tokens_neox': 961, 'n_words': 234}