<commit_before>var PLUGIN_NAME = 'gulp-check-deps';

var through = require('through2'),
    util = require('gulp-util'),
    semver = require('semver'),
    Table = require('cli-table'),
    assign = require('object-assign'),
    spawn = require('child_process').spawn,
    path = require('path');

require('colors');

var levels = {
        none: 3,
        major: 2,
        minor: 1,
        patch: 0
    },
    defaults = {
        npmPath: 'npm',
        npmArgs: [],
        failForDevDependencies: true,
        failForGitDependencies: false,
        failForPrerelease: true,
        failLevel: levels.minor,
        ignore: []
    },
    checkDeps = function(config) {
        config = assign({}, defaults, config);

        var stream = through.obj(function(file, enc, cb) {
            var npmWorkingDirectory = path.dirname(file.path),
                packageJson = JSON.parse(file.contents.toString()),
                outdated = spawn(config.npmPath, ['outdated', '--json', '--long'].concat(config.npmArgs), { cwd: npmWorkingDirectory }),
                outdatedData = '';

            outdated.stdout.on('data', function(chunk) { outdatedData += chunk.toString(); });
            outdated.stdout.on('end', function() {
                var json;

                try {
                    json = JSON.parse(outdatedData);
                } catch (e) {
                    json = {};
                }

                var deps = [],
                    notices = {},
                    errors = [],
                    gitStr = 'git'.green,
                    majorStr = 'major'.green.bold,
                    minorStr = 'minor'.green.bold,
                    patchStr = 'patch'.green.bold,
                    addError = function(depName, latest) {
                        if (
                            (json[depName].type !== 'devDependencies' || config.failForDevDependencies === true) &&
                            (isPrerelease(latest) === false || config.failForPrerelease === true) &&
                            config.ignore.indexOf(depName) === -1
                        ) {
                            errors.push(depName);
                        }
                    },
                    isPrerelease = function(version) {
                        return /-(?:alpha|beta|rc)(?:\.\d+)?$/.test(version);
                    };

                Object.keys(json).forEach(function(depName) {
                    var dep = json[depName];
<commit_msg>feat: Display NPM messages in case of error<commit_after>var PLUGIN_NAME = 'gulp-check-deps';

var through = require('through2'),
    util = require('gulp-util'),
    semver = require('semver'),
    Table = require('cli-table'),
    assign = require('object-assign'),
    spawn = require('child_process').spawn,
    path = require('path');

require('colors');

var levels = {
        none: 3,
        major: 2,
        minor: 1,
        patch: 0
    },
    defaults = {
        npmPath: 'npm',
        npmArgs: [],
        failForDevDependencies: true,
        failForGitDependencies: false,
        failForPrerelease: true,
        failLevel: levels.minor,
        ignore: []
    },
    checkDeps = function(config) {
        config = assign({}, defaults, config);

        var stream = through.obj(function(file, enc, cb) {
            var npmWorkingDirectory = path.dirname(file.path),
                packageJson = JSON.parse(file.contents.toString()),
                outdated = spawn(config.npmPath, ['outdated', '--json', '--long'].concat(config.npmArgs), { cwd: npmWorkingDirectory }),
                outdatedData = '',
                npmErrored = false;

            outdated.stdout.on('data', function(chunk) { outdatedData += chunk.toString(); });

            outdated.on('exit', function(code) {
                if (code === 0) {
                    return;
                }

                var error = '';

                while ((chunk = outdated.stderr.read()) !== null) {
                    error += chunk;
                }

                error.split('\n').forEach(function (row) {
                    util.log(row);
                });

                npmErrored = true;
                cb(new util.PluginError(PLUGIN_NAME, 'NPM exited with an error status: ' + code));
            });

            outdated.on('exit', function(code) {
                if (code !== 0) {
                    return;
                }

                var json;

                try {
                    json = JSON.parse(outdatedData);
                } catch (e) {
                    json = {};;
                }

                var deps = [],
                    notices = {},
                    errors = [],
                    gitStr = 'git'.green,
                    majorStr = 'major'.green.bold,
                    minorStr = 'minor'.green.bold,
                    patchStr = 'patch'.green.bold,
                    addError = function(depName, latest) {
                        if (
                            (json[depName].type !== 'devDependencies' || config.failForDevDependencies === true) &&
                            (isPrerelease(latest) === false || config.failForPrerelease === true) &&
                            config.ignore.indexOf(depName) === -1
                        ) {
                            errors.push(depName);
                        }
                    },
                    isPrerelease = function(version) {
                        return /-(?:alpha|beta|rc)(?:\.\d+)?$/.test(version);
                    };

                Object.keys(json).forEach(function(depName) {
                    var dep = json[depName];

{'fraction_non_alphanumeric': 0.13345101500441306, 'fraction_numerical': 0.002471315092674316, 'mean_word_length': 1.3211798443260958, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1928035', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1402, 'n_words': 271}