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


var resolve = require('resolve');
var path = require('path');
var fs = require('fs');

if (process.argv.length !== 3) {
  throw new Error("Need exactly one arg to reasonLoadEnv.js");
}

var curDir = process.argv.slice(2)[0];

const KEYS = [
  'dependencies',
  'peerDependencies',
];
var visited = {};

function resolveDep(dependency, dirs) {
    for (var dir of dirs) {
        try {
            return resolve.sync(
                path.join(dependency, 'package.json'),
                {basedir: dir}
            );
        } catch (err) { }
    }
    throw "cannot find " + dependency + " in " + dirs;
}

function traverseSync(filename, handler) {
  const pkg = JSON.parse(
    fs.readFileSync(filename, 'utf8')
  );
  handler(filename, pkg);
  KEYS.forEach(function(key) {
    Object.keys(
      pkg[key] || {}
    ).forEach(function(dependency) {
      var pJson = path.join(dependency, 'package.json');
      if (!visited[pJson]) {
        try {
          const resolved = resolveDep(dependency, [curDir, path.dirname(filename)]);
          // We won't traverse transitive dependencies because this is to be used
          // only post installation, for the sake of building, and also because
          // you shouldn't be *able* to rely on binaries or environment variables
          // from dependencies you didn't model.
          visited[pJson] = true;
          traverseSync(resolved, handler);
          //
          // We might want to allow two modes, however - so that transitive
          // dependencies can build up paths for linking etc.  But if we go that
          // far, you probably want to use a custom build system anyways.
        } catch (err) {
          // We are forgiving on optional dependencies -- if we can't find them,
          // just skip them
          if (pkg["optionalDependencies"] && pkg["optionalDependencies"][dependency]) {
            return;
          }
          throw err;
        }
      }
    });
  });
}


var cmds = [];
var seenVars = {};

function traverse(filePath, packageJson) {
  var packageJsonDir = path.dirname(filePath);
  var envPaths = packageJson.exportedEnvVars;
  var packageName = packageJson.name;
  var envVarScopePrefix =
    packageName.replace(new RegExp("\-", "g"), function(s){return "_";}).toUpperCase() + "__";
  for (var envVar in envPaths) {<commit_msg>Some minor cleanup/variable renames.<commit_after>#!/usr/bin/env node


var resolve = require('resolve');
var path = require('path');
var fs = require('fs');

if (process.argv.length !== 3) {
  throw new Error("Need exactly one arg to reasonLoadEnv.js");
}

var curDir = process.argv.slice(2)[0];

const KEYS = [
  'dependencies',
  'peerDependencies',
];
var visited = {};

function resolveDep(dependency, dirs) {
    for (var dir of dirs) {
        try {
            return resolve.sync(
                path.join(dependency, 'package.json'),
                {basedir: dir}
            );
        } catch (err) { }
    }
    throw "cannot find " + dependency + " in " + dirs;
}

function traverseSync(absolutePathToPackageJson, handler) {
  const pkg = JSON.parse(
    fs.readFileSync(absolutePathToPackageJson, 'utf8')
  );
  handler(absolutePathToPackageJson, pkg);
  KEYS.forEach(function(key) {
    Object.keys(
      pkg[key] || {}
    ).forEach(function(dependencyName) {
      if (!visited[dependencyName]) {
        try {
          const resolved = resolveDep(dependencyName, [curDir, path.dirname(absolutePathToPackageJson)]);
          // We won't traverse transitive dependencies because this is to be used
          // only post installation, for the sake of building, and also because
          // you shouldn't be *able* to rely on binaries or environment variables
          // from dependencies you didn't model.
          visited[dependencyName] = true;
          traverseSync(resolved, handler);
          //
          // We might want to allow two modes, however - so that transitive
          // dependencies can build up paths for linking etc.  But if we go that
          // far, you probably want to use a custom build system anyways.
        } catch (err) {
          // We are forgiving on optional dependencies -- if we can't find them,
          // just skip them
          if (pkg["optionalDependencies"] && pkg["optionalDependencies"][dependencyName]) {
            return;
          }
          throw err;
        }
      }
    });
  });
}


var cmds = [];
var seenVars = {};

function traverse(filePath, packageJson) {
  var packageJsonDir = path.dirname(filePath);
  var envPaths = packageJson.exportedEnvVars;
  var packageName = packageJson.name;
  var envVarScopePrefix =
    packageName.replace(new RegExp("\-", "g"), function(s){return "_";}).toUpperCase() + "__";
  for (var envVar in envPaths) {
{'fraction_non_alphanumeric': 0.12167221297836939, 'fraction_numerical': 0.0016638935108153079, 'mean_word_length': 2.4923747276688455, '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': '74834', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1344, 'n_words': 415}