<commit_before>var path = require('path');
var child = require('child_process');
var glob = require('glob');
var chrono = require('chrono');

var path_sep = process.platform === 'win32' ? '\\' : '/';

function display_crash_log(callback) {
    try {
        if (process.platform == 'darwin') {
            var now = new Date();
            var crash_path = path.join(process.env.HOME, 'Library/Logs/DiagnosticReports');
            var search = crash_path + '/node_' + now.format('Y-m-d') + '-*.crash';
            glob(search, {}, function(err, files) {
                if (files.length > 0) {
                    console.warn('found ' + files.length + ' crash logs for node');
                    // grab the latest
                    var latest = files[files.length - 1];
                    callback(null, latest);
                } else {
                    console.log('no crash logs found');
                    callback(null, null);
                }
            });
        } else if (process.platform === 'win32') {
            var crash_path = path.join(process.env.HOME, 'AppData/Local/Microsoft/Windows/WER/ReportArchive/');
            // normalize to unix paths to that glob works
            crash_path = crash_path.replace(/\\/g, '/');
            var options = {cwd: crash_path};
            var pattern = 'AppCrash_node.exe_*';
            glob(pattern, options, function(err, files) {
                if (files.length > 0) {
                    console.log('found ' + files.length + ' crash logs for node');
                    // grab the latest
                    var latest = path.join(crash_path, files[files.length - 1]);
                    callback(null, latest);
                } else {
                    console.log('no crash logs found');
                    callback(null, null);
                }
            });
        } else {
            callback(null, null);
        }
    } catch (err) {
        callback(err);
    }
}

module.exports = {
    display_crash_log: display_crash_log
};<commit_msg>make crash detector's glob sync for more predictable output during shutdown<commit_after>var path = require('path');
var child = require('child_process');
var glob = require('glob');
var chrono = require('chrono');

var path_sep = process.platform === 'win32' ? '\\' : '/';

function display_crash_log(callback) {
    try {
        if (process.platform == 'darwin') {
            var now = new Date();
            var crash_path = path.join(process.env.HOME, 'Library/Logs/DiagnosticReports');
            var search = crash_path + '/node_' + now.format('Y-m-d') + '-*.crash';
            var files = glob.sync(search);
            if (files.length > 0) {
                console.warn('[tilemill] found ' + files.length + ' crash logs for node');
                // grab the latest
                var latest = files[files.length - 1];
                return callback(null, latest);
            } else {
                console.log('[tilemill] no crash logs found');
                return callback(null, null);
            }
        } else if (process.platform === 'win32') {
            var crash_path = path.join(process.env.HOME, 'AppData/Local/Microsoft/Windows/WER/ReportArchive/');
            // normalize to unix paths to that glob works
            crash_path = crash_path.replace(/\\/g, '/');
            var options = {cwd: crash_path};
            var pattern = 'AppCrash_node.exe_*';
            var files = glob.sync(search);
            if (files.length > 0) {
                console.warn('[tilemill] found ' + files.length + ' crash logs for node');
                // grab the latest
                var latest = path.join(crash_path, files[files.length - 1]);
                return callback(null, latest);
            } else {
                console.log('[tilemill] no crash logs found');
                return callback(null, null);
            }
        } else {
            return callback(null, null);
        }
    } catch (err) {
        return callback(err);
    }
}

module.exports = {
    display_crash_log: display_crash_log
};
{'fraction_non_alphanumeric': 0.13302416402245545, 'fraction_numerical': 0.003905296558457408, 'mean_word_length': 1.6942800788954635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7509955', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1100, 'n_words': 275}