<commit_before>// Run only by vendor node.
// In an ideal world this would be run in the same process/context of
// atom-shell but there are many hurdles atm, see
// https://github.com/atom/atom-shell/issues/533
var tm = require('./lib/tm');
var path = require('path');
var getport = require('getport');
var server;

// increase the libuv threadpool size to 1.5x the number of logical CPUs.
process.env.UV_THREADPOOL_SIZE = Math.ceil(Math.max(4, require('os').cpus().length * 1.5));

process.title = 'tm2';

if (process.platform === 'win32') {
    // HOME is undefined on windows
    process.env.HOME = process.env.USERPROFILE;
    // Add custom library paths to the PATH
    process.env.PATH = path.join(__dirname,'node_modules/mapnik/lib/binding/');
}

var config = require('minimist')(process.argv.slice(2));
config.db = config.db || path.join(process.env.HOME, '.tilemill', 'v2', 'app.db');
config.mapboxauth = config.mapboxauth || 'https://api.mapbox.com';
config.port = config.port || undefined;
config.test = config.test || false;
config.cwd = path.resolve(config.cwd || process.env.HOME);

if (!config.port) {
    getport(3000, 3999, configure);
} else {
    configure();
}

function configure(err, port) {
    if (err) throw err;
    config.port = config.port || port;
    tm.config(config, listen);
}

function listen(err) {
    if (err) throw err;<commit_msg>Make sure env vars are set before require'ing tm lib.<commit_after>// Run only by vendor node.
// In an ideal world this would be run in the same process/context of
// atom-shell but there are many hurdles atm, see
// https://github.com/atom/atom-shell/issues/533
var path = require('path');
var getport = require('getport');

// increase the libuv threadpool size to 1.5x the number of logical CPUs.
process.env.UV_THREADPOOL_SIZE = Math.ceil(Math.max(4, require('os').cpus().length * 1.5));

process.title = 'tm2';

if (process.platform === 'win32') {
    // HOME is undefined on windows
    process.env.HOME = process.env.USERPROFILE;
    // Add custom library paths to the PATH
    process.env.PATH = path.join(__dirname,'node_modules/mapnik/lib/binding/');
}

var tm = require('./lib/tm');
var server;
var config = require('minimist')(process.argv.slice(2));
config.db = config.db || path.join(process.env.HOME, '.tilemill', 'v2', 'app.db');
config.mapboxauth = config.mapboxauth || 'https://api.mapbox.com';
config.port = config.port || undefined;
config.test = config.test || false;
config.cwd = path.resolve(config.cwd || process.env.HOME);

if (!config.port) {
    getport(3000, 3999, configure);
} else {
    configure();
}

function configure(err, port) {
    if (err) throw err;
    config.port = config.port || port;
    tm.config(config, listen);
}

function listen(err) {
    if (err) throw err;
{'fraction_non_alphanumeric': 0.15971223021582734, 'fraction_numerical': 0.015107913669064749, 'mean_word_length': 3.8197573656845756, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '864926', 'n_tokens_mistral': 934, 'n_tokens_neox': 909, 'n_words': 252}