<commit_before>#!/usr/bin/env node
var path    = require('path'),
    fs      = require('fs'),
    config  = require('./config.js'),
    spawn   = require('child_process').spawn;

console.log("Generating index file:")
console.log("  %s", config.SEARCH_INDEX),
console.log("from %s, ref:%s...", config.SEARCH_REPO, config.SEARCH_REF);

var tmp = config.SEARCH_INDEX + ".tmp";

var cs = spawn(path.join(__dirname, '..', 'codesearch'),
               ['--git_dir', path.join(config.SEARCH_REPO, ".git"),
                '--dump_index', tmp,
                '--order_root', config.ORDER_DIRS.join(' '),
                config.SEARCH_REF] + config.SEARCH_ARGS,
               {
                 customFds: [-1, 1, 2]
               });
cs.on('exit', function(code) {
        if (code !== 0)
          console.error("Index process exited with error %d", code);
        fs.renameSync(tmp, config.SEARCH_INDEX);
        process.exit(0);
      });
cs.stdin.end();<commit_msg>Right, Javascript doesn't do + on arrays.<commit_after>#!/usr/bin/env node
var path    = require('path'),
    fs      = require('fs'),
    config  = require('./config.js'),
    spawn   = require('child_process').spawn;

console.log("Generating index file:")
console.log("  %s", config.SEARCH_INDEX),
console.log("from %s, ref:%s...", config.SEARCH_REPO, config.SEARCH_REF);

var tmp = config.SEARCH_INDEX + ".tmp";

var cs = spawn(path.join(__dirname, '..', 'codesearch'),
               ['--git_dir', path.join(config.SEARCH_REPO, ".git"),
                '--dump_index', tmp,
                '--order_root', config.ORDER_DIRS.join(' '),
                config.SEARCH_REF].concat(config.SEARCH_ARGS),
               {
                 customFds: [-1, 1, 2]
               });
cs.on('exit', function(code) {
        if (code !== 0)
          console.error("Index process exited with error %d", code);
        fs.renameSync(tmp, config.SEARCH_INDEX);
        process.exit(0);
      });
cs.stdin.end();
{'fraction_non_alphanumeric': 0.18209562563580875, 'fraction_numerical': 0.00508646998982706, 'mean_word_length': 2.3282571912013537, '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': '1818265', 'n_tokens_mistral': 649, 'n_tokens_neox': 631, 'n_words': 121}