<commit_before>var net = require("net");
var repl = require("repl");
var fs = require('fs');
var path = require('path');
var logger = require('./logger');
var log = require('davlog');
var options = require('./args');
var one = require('./one');

var pipedStreams = [];

function liveLog() {
    pipedStreams.push(this.outputStream);
    logger.writer.pipe(this.outputStream);
}

var logDef = {
    help: 'live logs',
    action: liveLog
};

module.exports = function () {
    net.createServer(function (socket) {
        var thisOutputStream;
        socket.write('\n.help for help\n');
        socket.on('error', function(e){
            log.info('repl client has disconnected');
            if (thisOutputStream) {
                logger.writer.unpipe(thisOutputStream);
            }
        });
        var telnetRepl = repl.start({
            prompt: "registry-static > ",
            input: socket,
            output: socket,

        }).on('exit', function() {
            log.info('repl client has disconnected');
            if (thisOutputStream) {
                logger.writer.unpipe(thisOutputStream);
            }
            socket.end();
        });

        // defineCommand gives us .commands
        telnetRepl.defineCommand('log', {
            help: 'live logs',
            action: function liveLog() {
                thisOutputStream = this.outputStream;
                logger.writer.pipe(this.outputStream);
            }
        });
        telnetRepl.context.one = function(name) {
            one(name, function(err) {
                if (err) {
                    return console.log(err.stack);
                }
            });
        };
    }).listen(options.replport);
};<commit_msg>implement  in repl correctly<commit_after>var net = require("net");
var repl = require("repl");
var fs = require('fs');
var path = require('path');
var logger = require('./logger');
var log = require('davlog');
var options = require('./args');
var one = require('./one');

var pipedStreams = [];

function liveLog() {
    pipedStreams.push(this.outputStream);
    logger.writer.pipe(this.outputStream);
}

var logDef = {
    help: 'live logs',
    action: liveLog
};

module.exports = function () {
    net.createServer(function (socket) {
        var thisOutputStream;
        socket.write('\n.help for help\n');
        socket.on('error', function(e){
            log.info('repl client has disconnected');
            if (thisOutputStream) {
                logger.writer.unpipe(thisOutputStream);
            }
        });
        var telnetRepl = repl.start({
            prompt: "registry-static > ",
            input: socket,
            output: socket,

        }).on('exit', function() {
            log.info('repl client has disconnected');
            if (thisOutputStream) {
                logger.writer.unpipe(thisOutputStream);
            }
            socket.end();
        });

        // defineCommand gives us .commands
        telnetRepl.defineCommand('log', {
            help: 'live logs',
            action: function liveLog() {
                thisOutputStream = this.outputStream;
                logger.writer.pipe(this.outputStream);
            }
        });
        telnetRepl.defineCommand('one', {
            help: 'sync one package (e.g. `.one async`)',
            action: function(name) {
                var self = this;
                one(name, function(err) {
                    if (err) {
                        self.outputStream.write("`one('"+name+"')` did not complete successfully. It gave the following error:\n");
                        self.outputStream.write(err.stack);
                        self.outputStream.write('\n');
                    } else {
                        self.outputStream.write("`one('"+name+"')` completed successfully.\n");
                    }
                    self.displayPrompt();
                });
                self.outputStream.write("`one('"+name+"')` is now running...\n");
            }
        });
    }).listen(options.replport);
};
{'fraction_non_alphanumeric': 0.14218711429276723, 'fraction_numerical': 0.0, 'mean_word_length': 1.7639836289222375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3454774', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1054, 'n_words': 227}