<commit_before>/**
 * Ngrok wrapper script
 * http://www.ngrok.com
 *
 * it will generate random subdomain if you don't provide subdomain name in -subdomain svh option
 *
 * Created by <NAME>. on 10/12/13.
 */

var spawn = require('child_process').spawn
    , message = require('../middleware/message')
    , generator = require('../middleware/randname')
    , ngrok_path = '/usr/bin/ngrok'
    , arg_log = '-log=stdout'
    , argsArray = []
    , ngrok_output
    , ngrok_subdomain;

exports.expose = function (options) {

    argsArray.push(arg_log);
    if (options.auth !== '') argsArray.push('-httpauth=' + options.auth);

    if (options.subdomain !== null) {
        argsArray.push('-subdomain=' + options.subdomain);
        ngrok_output = 'ngrok url at http://' + options.subdomain + '.ngrok.com';
        message.output(ngrok_output);
        ngrok(options, argsArray);
    } else {
        // take random name so ngrok will always use words
        generator.generate(function (err, words) {
            ngrok_subdomain = words;
            ngrok_output = 'ngrok url at http://' + ngrok_subdomain + '.ngrok.com';
            message.output(ngrok_output);
            argsArray.push('-subdomain=' + ngrok_subdomain);
            ngrok(options, argsArray);
        });
    }
}

var ngrok = function (options, argsArray) {

    argsArray.push(options.port);

    var ngrokproc = spawn(ngrok_path, argsArray, {detached: true, stdio: 'ignore'});

    ngrokproc.on('close', function (code) {
        // cleanup
    });
}<commit_msg>serve ngrok binary path through command line option -N. default to '/usr/bin/ngrok'<commit_after>/**
 * Ngrok wrapper script
 * http://www.ngrok.com
 *
 * it will generate random subdomain if you don't provide subdomain name in -subdomain svh option
 *
 * Created by <NAME>. on 10/12/13.
 */

var spawn = require('child_process').spawn
    , message = require('../middleware/message')
    , generator = require('../middleware/randname')
    , arg_log = '-log=stdout'
    , argsArray = []
    , ngrok_output
    , ngrok_subdomain;

exports.expose = function (options) {

    argsArray.push(arg_log);
    if (options.auth !== '') argsArray.push('-httpauth=' + options.auth);

    if (options.subdomain !== null) {
        argsArray.push('-subdomain=' + options.subdomain);
        ngrok_output = 'ngrok url at http://' + options.subdomain + '.ngrok.com';
        message.output(ngrok_output);
        ngrok(options, argsArray);
    } else {
        // take random name so ngrok will always use words
        generator.generate(function (err, words) {
            ngrok_subdomain = words;
            ngrok_output = 'ngrok url at http://' + ngrok_subdomain + '.ngrok.com';
            message.output(ngrok_output);
            argsArray.push('-subdomain=' + ngrok_subdomain);
            ngrok(options, argsArray);
        });
    }
}

var ngrok = function (options, argsArray) {

    argsArray.push(options.port);

    var ngrokproc = spawn(options.ngrokpath, argsArray, {detached: true, stdio: 'ignore'});

    ngrokproc.on('close', function (code) {
        // cleanup
    });
}
{'fraction_non_alphanumeric': 0.1434991974317817, 'fraction_numerical': 0.0038523274478330658, 'mean_word_length': 2.7228195937873356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1024383', 'n_tokens_mistral': 983, 'n_tokens_neox': 1007, 'n_words': 223}