<commit_before>'use strict';

require('coffee-script/register');
var path             = require('path');
var util             = require('util');
var gutil            = require('gulp-util');
var through          = require('through2');
var jscpd            = require('jscpd');
var logger           = require('jscpd/node_modules/winston');
var TokenizerFactory = require('jscpd/src/tokenizer/TokenizerFactory');
var Mapper           = require('jscpd/src/map').Map;
var Strategy         = require('jscpd/src/strategy').Strategy;
var Report           = require('jscpd/src/report').Report;

logger.info = function() {};

module.exports = function(opts) {
  opts = opts || {};
  var cwd = opts.path || '.';
  var config = jscpd.prototype.readConfig(cwd + '/.cpd.yaml');
  opts = util._extend({
    'min-lines' : 5,
    'min-tokens': 70,
    languages   : jscpd.prototype.LANGUAGES,
    output      : null,
    path        : null,
    verbose     : false,
    debug       : false
  }, opts);
  opts = util._extend(opts, config);
  if (config.path) {
    opts.path = path.normalize(cwd + path.sep + config.path);
    cwd = opts.path;
  }
  opts.extensions = TokenizerFactory.prototype.getExtensionsByLanguages(opts.languages);<commit_msg>Silent the warning if .cpd.yaml is missing (fixes #1)<commit_after>'use strict';

require('coffee-script/register');
var path             = require('path');
var util             = require('util');
var gutil            = require('gulp-util');
var through          = require('through2');
var jscpd            = require('jscpd');
var logger           = require('jscpd/node_modules/winston');
var TokenizerFactory = require('jscpd/src/tokenizer/TokenizerFactory');
var Mapper           = require('jscpd/src/map').Map;
var Strategy         = require('jscpd/src/strategy').Strategy;
var Report           = require('jscpd/src/report').Report;

logger.info = function() {};
logger.warn = function() {};

module.exports = function(opts) {
  opts = opts || {};
  var cwd = opts.path || '.';
  var config = jscpd.prototype.readConfig(cwd + '/.cpd.yaml');
  opts = util._extend({
    'min-lines' : 5,
    'min-tokens': 70,
    languages   : jscpd.prototype.LANGUAGES,
    output      : null,
    path        : null,
    verbose     : false,
    debug       : false
  }, opts);
  opts = util._extend(opts, config);
  if (config.path) {
    opts.path = path.normalize(cwd + path.sep + config.path);
    cwd = opts.path;
  }
  opts.extensions = TokenizerFactory.prototype.getExtensionsByLanguages(opts.languages);
{'fraction_non_alphanumeric': 0.15275029679461813, 'fraction_numerical': 0.003561535417491096, 'mean_word_length': 2.750741839762611, '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': '1601402', 'n_tokens_mistral': 808, 'n_tokens_neox': 794, 'n_words': 161}