<commit_before>#!/usr/bin/env node
'use strict';

var csscombLinter = require('../lib/csscomb-linter')();
var reporter = require('../lib/reporter')();

process.stdin.isTTY ?
    processArgs() :
    lintBuffer();

process.on('exit', function () {
    process.exit(reporter.hasErrors() ? 2 : 0);
});

function lintBuffer() {
    process.stdin
        .pipe(csscombLinter())
        .pipe(reporter, {end: false});
}

function processArgs() {
    var program = require('commander');
    var pkg = require('../package');

    program
        .version(pkg.version)
        .parse(process.argv);

    if (program.args.length === 0) {
        program.help();
    }

    lintFiles(program.args);
}

/**
 * @param  {string[]} files
 */
function lintFiles(files) {
    var fs = require('fs');
    var path = require('path');

    files.forEach(function (file) {
        var filePath = path.resolve(file);

        fs.stat(filePath, function (err, stat) {
            if (err) {
                console.error(err.code === 'ENOENT' ?
                    filePath + ' not found!' : err);
                process.exit(1);
            }

            if (!stat.isFile()) {
                console.error(filePath + ' not a file!');
                process.exit(1);
            }

            lintFile(filePath);
        });
    });
}

/**
 * @param {String} filePath Absolute path.
 */
function lintFile(filePath) {
    var fs = require('fs');
    var path = require('path');

    var options = {
        filename: path.basename(filePath),
        syntax: path.extname(filePath).replace('.', '')<commit_msg>cheap solution for possible EventEmitter memory leak<commit_after>#!/usr/bin/env node
'use strict';

var csscombLinter = require('../lib/csscomb-linter')();
var reporter = require('../lib/reporter')();

process.stdin.isTTY ?
    processArgs() :
    lintBuffer();

process.on('exit', function () {
    process.exit(reporter.hasErrors() ? 2 : 0);
});

function lintBuffer() {
    process.stdin
        .pipe(csscombLinter())
        .pipe(reporter, {end: false});
}

function processArgs() {
    var program = require('commander');
    var pkg = require('../package');

    program
        .version(pkg.version)
        .parse(process.argv);

    if (program.args.length === 0) {
        program.help();
    }

    lintFiles(program.args);
}

/**
 * @param  {string[]} files
 */
function lintFiles(files) {
    var fs = require('fs');
    var path = require('path');

    // cheap solution
    reporter.setMaxListeners(files.length);

    files.forEach(function (file) {
        var filePath = path.resolve(file);

        fs.stat(filePath, function (err, stat) {
            if (err) {
                console.error(err.code === 'ENOENT' ?
                    filePath + ' not found!' : err);
                process.exit(1);
            }

            if (!stat.isFile()) {
                console.error(filePath + ' not a file!');
                process.exit(1);
            }

            lintFile(filePath);
        });
    });
}

/**
 * @param {String} filePath Absolute path.
 */
function lintFile(filePath) {
    var fs = require('fs');
    var path = require('path');

    var options = {
        filename: path.basename(filePath),
        syntax: path.extname(filePath).replace('.', '')
{'fraction_non_alphanumeric': 0.16656516443361755, 'fraction_numerical': 0.0030450669914738123, 'mean_word_length': 2.1647398843930636, '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': '4059375', 'n_tokens_mistral': 1037, 'n_tokens_neox': 994, 'n_words': 203}