<commit_before>#!/usr/bin/env node

var path = require('path');
var nconf = require('nconf');
var yamlLint = require('./yaml-lint');
var leprechaun = require('leprechaun');
var merge = require('lodash.merge');
var snakeCase = require('lodash.snakecase');
var glob = require('glob');
var Promise = require('bluebird');

var options = {};

nconf.argv().env({
  match: /^yamllint/i
}).file({
  file: path.resolve(process.cwd(), '.yaml-lint.json')
});

[
  'schema'
].forEach(function (key) {
  var env = snakeCase(key);
  options[key] = nconf.get(key) || nconf.get('yamllint_' + env.toLowerCase()) || nconf.get('YAMLLINT' + env.toUpperCase());
});

var config = nconf.get();

var files = [];

(config._ || []).forEach(function (file) {
  files = files.concat(glob.sync(file));
});

Promise.map(files, function (file) {
  return yamlLint.lintFile(file, options);
}).then(function () {
  leprechaun.success('YAML Lint successful.');
}).catch(function (error) {
  leprechaun.error('YAML Lint failed.');
  console.error(error.message);
  process.exit(1);
});<commit_msg>Implement check for empty file selections while using the CLI<commit_after>#!/usr/bin/env node

var path = require('path');
var nconf = require('nconf');
var yamlLint = require('./yaml-lint');
var leprechaun = require('leprechaun');
var merge = require('lodash.merge');
var snakeCase = require('lodash.snakecase');
var glob = require('glob');
var Promise = require('bluebird');

var options = {};

nconf.argv().env({
  match: /^yamllint/i
}).file({
  file: path.resolve(process.cwd(), '.yaml-lint.json')
});

[
  'schema'
].forEach(function (key) {
  var env = snakeCase(key);
  options[key] = nconf.get(key) || nconf.get('yamllint_' + env.toLowerCase()) || nconf.get('YAMLLINT' + env.toUpperCase());
});

var config = nconf.get();

var files = [];

(config._ || []).forEach(function (file) {
  files = files.concat(glob.sync(file));
});

if (files.length === 0) {

  leprechaun.error('YAML Lint failed.');
  console.error('No YAML files were found matching your selection.');
  process.exit(1);

} else {

  Promise.map(files, function (file) {
    return yamlLint.lintFile(file, options);
  }).then(function () {
    leprechaun.success('YAML Lint successful.');
  }).catch(function (error) {
    leprechaun.error('YAML Lint failed.');
    console.error(error.message);
    process.exit(1);
  });

}
{'fraction_non_alphanumeric': 0.2014388489208633, 'fraction_numerical': 0.0016927634363097758, 'mean_word_length': 4.696385542168675, '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': '6895823', 'n_tokens_mistral': 840, 'n_tokens_neox': 831, 'n_words': 173}