<commit_before>
var express = require("express");
var fs = require("graceful-fs");
var path = require("path");
var Q = require("q");
var http = require("http");
var xtend = require("xtend");
var args = require("./args");

var writeFile = Q.denodeify(fs.writeFile);
var readFile = Q.denodeify(fs.readFile);
var readdir = Q.denodeify(fs.readdir);
var stat = Q.denodeify(fs.stat);

Q.longStackSupport = true;


var app = express();

app.set("view engine", "hbs");
app.set("views", __dirname + "/views");

app.get("/", function(req, res, next) {

    readdir(args.directory).then(function(files) {
        var allMeta = files.filter(function(filePath) {
            return (/\.json$/).test(filePath);
        }).map(function(metaDataFile) {
            var metaDataFilePath = path.join(args.directory, metaDataFile);
            var fileName = metaDataFile.replace(/\.json$/, "");

            var meta = readFile(metaDataFilePath).then(function(data) {
                return JSON.parse(data.toString());
            });

            return Q.all([meta, stat(metaDataFilePath.replace(/\.json$/, ""))])
                .spread(function(metaData, fileStat) {
                    return xtend(metaData, fileStat, {
                        sha1: fileName
                    });
                });
        });

        return Q.all(allMeta);
    }).then(function(files) {
        console.log("FileS", files);
        res.render("index", {
            cacheDir: args.directory,
            files: files
        });
    }, next);


});<commit_msg>cleanup<commit_after>
var express = require("express");
var fs = require("graceful-fs");
var path = require("path");
var Q = require("q");
var http = require("http");
var xtend = require("xtend");
var args = require("./args");

var writeFile = Q.denodeify(fs.writeFile);
var readFile = Q.denodeify(fs.readFile);
var readdir = Q.denodeify(fs.readdir);
var stat = Q.denodeify(fs.stat);

Q.longStackSupport = true;


var app = express();

app.set("view engine", "hbs");
app.set("views", __dirname + "/views");

app.get("/", function(req, res, next) {

    readdir(args.directory).then(function(files) {
        var allMeta = files.filter(function(filePath) {
            return (/\.json$/).test(filePath);
        }).map(function(metaDataFile) {
            var metaDataFilePath = path.join(args.directory, metaDataFile);
            var fileName = metaDataFile.replace(/\.json$/, "");

            var meta = readFile(metaDataFilePath).then(function(data) {
                return JSON.parse(data.toString());
            });

            return Q.all([meta, stat(metaDataFilePath.replace(/\.json$/, ""))])
                .spread(function(metaData, fileStat) {
                    return xtend(metaData, fileStat, {
                        sha1: fileName
                    });
                });
        });

        return Q.all(allMeta);
    }).then(function(files) {
        res.render("index", {
            cacheDir: args.directory,
            files: files
        });
    }, next);


});
{'fraction_non_alphanumeric': 0.16705107084019769, 'fraction_numerical': 0.0006589785831960461, 'mean_word_length': 2.3362637362637364, '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': '4948264', 'n_tokens_mistral': 930, 'n_tokens_neox': 903, 'n_words': 176}