UNPKG

jscpd

Version:

Copy/paste detector for programming code, support JavaScript, CoffeeScript, PHP, Ruby, Python, Less, Go, Java, Yaml, C#, C++, C languages

63 lines (51 loc) 1.65 kB
// Generated by CoffeeScript 1.10.0 (function() { var TokenizerFactory, _, fs, optionsPreprocessor, path, prepareOptions, readConfig, yaml; _ = require("underscore"); yaml = require('js-yaml'); fs = require('fs'); path = require('path'); TokenizerFactory = require('../tokenizer/TokenizerFactory'); prepareOptions = function(options, config) { var key, optionsNew, value; optionsNew = _.extend(optionsPreprocessor["default"], config); for (key in options) { value = options[key]; if (!(value === null)) { optionsNew[key] = value; } } if (typeof optionsNew.languages === 'string') { optionsNew.languages = optionsNew.languages.split(','); } optionsNew.extensions = TokenizerFactory.prototype.getExtensionsByLanguages(optionsNew.languages); return optionsNew; }; readConfig = function(file) { var doc, error, error1; file = path.normalize(file); try { doc = yaml.safeLoad(fs.readFileSync(file, 'utf8')); doc.config_file = file; return doc; } catch (error1) { error = error1; return false; } }; optionsPreprocessor = function(jscpd) { var config, options; config = readConfig('.cpd.yaml') || readConfig('.cpd.yml') || {}; options = prepareOptions(jscpd.options, config); options.path = options.path || process.cwd(); return jscpd.options = options; }; optionsPreprocessor["default"] = { languages: Object.keys(TokenizerFactory.prototype.LANGUAGES), verbose: false, debug: false, files: null, exclude: null }; module.exports = optionsPreprocessor; }).call(this);