<commit_before>/*
 * Copyright 2013-2015, All Rights Reserved.
 *
 * Code licensed under the BSD License:
 * https://github.com/node-gh/gh/blob/master/LICENSE.md
 *
 * @author <NAME> <<EMAIL>>
 */

'use strict';

var configs = require('./configs'),
    fs = require('fs'),
    github = require('github'),
    path = require('path'),
    updateNotifier = require('update-notifier');

// -- Config -------------------------------------------------------------------

exports.clone = function(o) {
    return JSON.parse(JSON.stringify(o));
};

// -- Utils --------------------------------------------------------------------

var baseConfig = configs.getConfig();

exports.github = new github({
    debug: false,
    host: baseConfig.api.host,
    protocol: baseConfig.api.protocol,
    version: baseConfig.api.version
});

exports.asyncReadPackages = function(callback) {
    function async(err, data) {
        if (err) {
            throw err;
        }

        callback(JSON.parse(data));
    }

    fs.readFile(path.join(__dirname, '..', 'package.json'), async);

    configs.getPlugins().forEach(function(plugin) {
        fs.readFile(path.join(
            configs.getNodeModulesGlobalPath(), plugin, 'package.json'), async);
    });
};

exports.notifyVersion = function(pkg) {
    var notifier = updateNotifier({
        packageName: pkg.name,
        packageVersion: pkg.version
    });

    if (notifier.update) {<commit_msg>Adding tracking of version update.<commit_after>/*
 * Copyright 2013-2015, All Rights Reserved.
 *
 * Code licensed under the BSD License:
 * https://github.com/node-gh/gh/blob/master/LICENSE.md
 *
 * @author <NAME> <<EMAIL>>
 */

'use strict';

var configs = require('./configs'),
    fs = require('fs'),
    github = require('github'),
    path = require('path'),
    tracker = require('./tracker'),
    updateNotifier = require('update-notifier');

// -- Config -------------------------------------------------------------------

exports.clone = function(o) {
    return JSON.parse(JSON.stringify(o));
};

// -- Utils --------------------------------------------------------------------

var baseConfig = configs.getConfig();

exports.github = new github({
    debug: false,
    host: baseConfig.api.host,
    protocol: baseConfig.api.protocol,
    version: baseConfig.api.version
});

exports.asyncReadPackages = function(callback) {
    function async(err, data) {
        if (err) {
            throw err;
        }

        callback(JSON.parse(data));
    }

    fs.readFile(path.join(__dirname, '..', 'package.json'), async);

    configs.getPlugins().forEach(function(plugin) {
        fs.readFile(path.join(
            configs.getNodeModulesGlobalPath(), plugin, 'package.json'), async);
    });
};

exports.notifyVersion = function(pkg) {
    var notifier = updateNotifier({pkg: pkg}),
        update,
        track = 'notify/';

    if (notifier.update) {
        update = notifier.update;

        track += update.name + '/' + update.latest + '/from/' + update.current;

        tracker.track(track);

{'fraction_non_alphanumeric': 0.23450311577566416, 'fraction_numerical': 0.005247622171203673, 'mean_word_length': 2.080808080808081, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '5671016', 'n_tokens_mistral': 883, 'n_tokens_neox': 854, 'n_words': 172}