<commit_before>'use strict';

var getLicense = require('licenses');
var async = require('async');
var getPackageJSON = require('package-json');

module.exports = function(packageJSON, maxDepth, callback) {

  var licenses = {};

  traverse(packageJSON, 0, maxDepth, licenses, callback);
};

function traverse(packageJSON, depth, maxDepth, licenses, callback) {

  var deps;

  if(depth < maxDepth && packageJSON.dependencies) {

    // setup a structure that has name + version in an array
    deps = Object.keys(packageJSON.dependencies).map( function(depName) {

      return [ depName, getVersion(packageJSON.dependencies[ depName ]) ];
    });

    // now get the license for the current dependencies
    getLicensesForDeps(deps, function(err, depLicenses) {

      // add licenses to dependencies
      licenses.dependencies = depLicenses;

      getPackageJSONForDeps(deps, function(err, depPackageJSON) {

        // add packageJSON to the deps
        deps = deps.map( function(cDep, i) {
<commit_msg>Added a check to see if we got a package.json<commit_after>'use strict';

var getLicense = require('licenses');
var async = require('async');
var getPackageJSON = require('package-json');

module.exports = function(packageJSON, maxDepth, callback) {

  var licenses = {};

  traverse(packageJSON, 0, maxDepth, licenses, callback);
};

function traverse(packageJSON, depth, maxDepth, licenses, callback) {

  var deps;

  if(packageJSON && depth < maxDepth && packageJSON.dependencies) {

    // setup a structure that has name + version in an array
    deps = Object.keys(packageJSON.dependencies).map( function(depName) {

      return [ depName, getVersion(packageJSON.dependencies[ depName ]) ];
    });

    // now get the license for the current dependencies
    getLicensesForDeps(deps, function(err, depLicenses) {

      // add licenses to dependencies
      licenses.dependencies = depLicenses;

      getPackageJSONForDeps(deps, function(err, depPackageJSON) {

        // add packageJSON to the deps
        deps = deps.map( function(cDep, i) {

{'fraction_non_alphanumeric': 0.1108958837772397, 'fraction_numerical': 0.0009685230024213075, 'mean_word_length': 3.884160756501182, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2051543', 'n_tokens_mistral': 613, 'n_tokens_neox': 574, 'n_words': 168}