<commit_before>var fs = require("fs");
var spawn = require("child_process").spawn;
var tmp = require("tmp");
var path = require("path");
var templatesDir = path.join(__dirname, "templates");
var compile = require("node-elm-compiler").compile;
var emitterFilename = "emitter.js";


// TODO: externalize all this and make it configurable
var srcFile = "examples/src/HomepageStylesheet.elm";
var elmModuleName = "HomepageStylesheet";
var destCssFile = path.join(__dirname, "output.css")
process.chdir("examples")
// END TODO


tmp.dir({unsafeCleanup: true}, function (err, tmpDirPath, cleanup) {
  if (err) {
    throw err;
  }

  var emitterDest = path.join(tmpDirPath, emitterFilename);

  compileEmitter({
    output: emitterDest
  }, function() {
    // Make the compiled emitter.js Node-friendly.
    fs.appendFileSync(emitterDest, "\nmodule.exports = Elm;");

    var Elm = require(emitterDest);
    var compiledCss = Elm.worker(Elm[elmModuleName]).ports.css;

    fs.writeFileSync(destCssFile, compiledCss);
  }, function(exitCode) {
    console.error("Errored with exit code", exitCode);

    process.exit(exitCode);
  });
});

function compileEmitter(options, onSuccess, onError) {
  compile(path.join(__dirname, srcFile), options)
    .on("close", function(exitCode) {
      if (exitCode === 0) {
        onSuccess()
      } else {
        onError(exitCode);
      }<commit_msg>Put a newline at the end of the compiled CSS for great POSIX justice.<commit_after>var fs = require("fs");
var spawn = require("child_process").spawn;
var tmp = require("tmp");
var path = require("path");
var templatesDir = path.join(__dirname, "templates");
var compile = require("node-elm-compiler").compile;
var emitterFilename = "emitter.js";


// TODO: externalize all this and make it configurable
var srcFile = "examples/src/HomepageStylesheet.elm";
var elmModuleName = "HomepageStylesheet";
var destCssFile = path.join(__dirname, "output.css")
process.chdir("examples")
// END TODO


tmp.dir({unsafeCleanup: true}, function (err, tmpDirPath, cleanup) {
  if (err) {
    throw err;
  }

  var emitterDest = path.join(tmpDirPath, emitterFilename);

  compileEmitter({
    output: emitterDest
  }, function() {
    // Make the compiled emitter.js Node-friendly.
    fs.appendFileSync(emitterDest, "\nmodule.exports = Elm;");

    var Elm = require(emitterDest);
    var compiledCss = Elm.worker(Elm[elmModuleName]).ports.css + "\n";

    fs.writeFileSync(destCssFile, compiledCss);
  }, function(exitCode) {
    console.error("Errored with exit code", exitCode);

    process.exit(exitCode);
  });
});

function compileEmitter(options, onSuccess, onError) {
  compile(path.join(__dirname, srcFile), options)
    .on("close", function(exitCode) {
      if (exitCode === 0) {
        onSuccess()
      } else {
        onError(exitCode);
      }
{'fraction_non_alphanumeric': 0.14225202965054712, 'fraction_numerical': 0.0007059654076950229, 'mean_word_length': 4.171532846715328, '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': '4948230', 'n_tokens_mistral': 910, 'n_tokens_neox': 875, 'n_words': 212}