<commit_before>'use strict';

var detective = require('detective-cjs');
var log = require('debug')('galvatron:matcher:commonjs');

module.exports = function ($fs) {
  return function (file, code) {
    if (!code) {
      return [];
    }

    return detective(code).map(function (imp) {
      log('resolving commonjs dependency', imp, 'from', file);
      return {
        path: $fs.ext($fs.resolve(imp, file), 'js', ['js', 'json']),
        value: imp
      };
    });
  };
};<commit_msg>Better debugging.<commit_after>'use strict';

var detective = require('detective-cjs');
var log = require('debug')('galvatron:matcher:commonjs');

module.exports = function ($fs) {
  return function (file, code) {
    if (!code) {
      return [];
    }

    return detective(code).map(function (impValue) {
      var cwd = process.cwd() + '/';
      var impPath = $fs.ext($fs.resolve(impValue, file), 'js', ['js', 'json']);
      log('import', file.replace(cwd, ''), '->', impPath.replace(cwd, ''));
      return {
        path: impPath,
        value: impValue
      };
    });
  };
};
{'fraction_non_alphanumeric': 0.1970260223048327, 'fraction_numerical': 0.0, 'mean_word_length': 3.0795454545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '2191718', 'n_tokens_mistral': 356, 'n_tokens_neox': 349, 'n_words': 76}