<commit_before>var treeSitter = require("../../index"),
    fs = require("fs"),
    path = require("path"),
    mkdirp = require("mkdirp"),
    cp = require("ncp"),
    templates = require("./templates"),
    cwd = process.cwd();

module.exports = function compile() {
  require("coffee-script/register");
  var grammar = require(path.join(cwd, "grammar.coffee"));

  mkdirp.sync(path.join(cwd, "src"));
  fs.writeFileSync(path.join(cwd, "src", "parser.c"), treeSitter.compile(grammar));
  fs.writeFileSync(path.join(cwd, "src", "binding.cc"), templates.bindingCC(grammar.name));
  fs.writeFileSync(path.join(cwd, "binding.gyp"), templates.bindingGyp(grammar.name));
  fs.writeFileSync(path.join(cwd, "index.js"), templates.indexJS(grammar.name));
  fs.writeFileSync(path.join(cwd, "grammar.json"), JSON.stringify(grammar, null, 2));

  cp(
    path.join(__dirname, "..", "..", "vendor", "tree-sitter", "include"),
    path.join(cwd, "include"),
    function(err) {
      if (err) {
        console.log("Error: ", err);
      }
    });
}<commit_msg>Add progress output to cli compile command<commit_after>var treeSitter = require("../../index"),
    fs = require("fs"),
    path = require("path"),
    mkdirp = require("mkdirp"),
    cp = require("ncp"),
    templates = require("./templates"),
    cwd = process.cwd();

module.exports = function compile() {

  require("coffee-script/register");
  var grammar = require(path.join(cwd, "grammar.coffee"));

  process.stdout.write("Generating parser... ");
  var startTime = process.hrtime();

  mkdirp.sync(path.join(cwd, "src"));
  fs.writeFileSync(path.join(cwd, "src", "parser.c"), treeSitter.compile(grammar));
  fs.writeFileSync(path.join(cwd, "src", "binding.cc"), templates.bindingCC(grammar.name));
  fs.writeFileSync(path.join(cwd, "binding.gyp"), templates.bindingGyp(grammar.name));
  fs.writeFileSync(path.join(cwd, "index.js"), templates.indexJS(grammar.name));
  fs.writeFileSync(path.join(cwd, "grammar.json"), JSON.stringify(grammar, null, 2));

  cp(
    path.join(__dirname, "..", "..", "vendor", "tree-sitter", "include"),
    path.join(cwd, "include"),
    function(err) {
      if (err) {
        console.log("Error: ", err);
      }
    });

  var endTime = process.hrtime(startTime);
  console.log("Done (%ds).", (endTime[0] + (endTime[1] / Math.pow(10, 9))).toFixed(2));
}
{'fraction_non_alphanumeric': 0.20971867007672634, 'fraction_numerical': 0.0034100596760443308, 'mean_word_length': 4.203991130820399, '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': '2596294', 'n_tokens_mistral': 838, 'n_tokens_neox': 810, 'n_words': 132}