<commit_before>// This still seems a little weird see https://github.com/Microsoft/TypeScript/issues/3337
import * as path from 'path';
import * as fs from 'fs';

import * as express from 'express';
import * as nconf from 'nconf';
import * as handlebars from 'handlebars';
import * as morgan from 'morgan';

import './config';

if (nconf.get('help')) {
  console.log('Usage: takepeek <args>\n');
  nconf.stores.argv.showHelp();
  console.log('Invert boolean options with "no" prefix (e.g. --no-index)\n');
  process.exit(0);
}

if (nconf.get('quiet')) {
  // Make console.log quiet
  console.log = function() {}
}

// Resolve the directory we are serving
const DIRECTORY = path.resolve(process.cwd(), nconf.get('directory'));

// Setup our index page
const indexTemplate = handlebars.compile(
  fs.readFileSync(path.resolve(__dirname, '../index.html')).toString()
);

const app = express();

// Log the requests
if (!nconf.get('quiet')) {
  app.use(morgan('dev'));
}

// Serve the directory
// Turn expresses indexes off, we are making our own
app.use(express.static(DIRECTORY, {
  index: false,
  setHeaders(res, path, stat) {
    if (nconf.get('content-text')) {
      res.set('Content-Type', 'text/plain');<commit_msg>Re-enable express's static index option<commit_after>// This still seems a little weird see https://github.com/Microsoft/TypeScript/issues/3337
import * as path from 'path';
import * as fs from 'fs';

import * as express from 'express';
import * as nconf from 'nconf';
import * as handlebars from 'handlebars';
import * as morgan from 'morgan';

import './config';

if (nconf.get('help')) {
  console.log('Usage: takepeek <args>\n');
  nconf.stores.argv.showHelp();
  console.log('Invert boolean options with "no" prefix (e.g. --no-index)\n');
  process.exit(0);
}

if (nconf.get('quiet')) {
  // Make console.log quiet
  console.log = function() {}
}

// Resolve the directory we are serving
const DIRECTORY = path.resolve(process.cwd(), nconf.get('directory'));

// Setup our index page
const indexTemplate = handlebars.compile(
  fs.readFileSync(path.resolve(__dirname, '../index.html')).toString()
);

const app = express();

// Log the requests
if (!nconf.get('quiet')) {
  app.use(morgan('dev'));
}

// Serve the directory
// Turn expresses indexes off, we are making our own
app.use(express.static(DIRECTORY, {
  setHeaders(res, path, stat) {
    if (nconf.get('content-text')) {
      res.set('Content-Type', 'text/plain');
{'fraction_non_alphanumeric': 0.16802610114192496, 'fraction_numerical': 0.004078303425774877, 'mean_word_length': 4.131799163179917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6833893', 'n_tokens_mistral': 805, 'n_tokens_neox': 789, 'n_words': 227}