<commit_before>const debug = require("debug")("workflow-compile");
const fse = require("fs-extra");
const { prepareConfig } = require("./utils");
const { shimContract } = require("@truffle/compile-solidity/legacy/shims");
const {
  reportCompilationStarted,
  reportNothingToCompile,
  reportCompilationFinished
} = require("./reports");

const SUPPORTED_COMPILERS = {
  solc: require("@truffle/compile-solidity"),
  vyper: require("@truffle/compile-vyper"),
  external: require("@truffle/external-compile")
};

async function compile(config) {
  // determine compiler(s) to use
  //
  const compilers = config.compiler
    ? config.compiler === "none"
      ? []
      : [config.compiler]
    : Object.keys(config.compilers);

  // invoke compilers
  //
  const rawCompilations = await Promise.all(
    compilers.map(async name => {
      const compiler = SUPPORTED_COMPILERS[name] || {};
      if (!compiler) throw new Error("Unsupported compiler: " + name);

      const compileMethod =
        config.all === true || config.compileAll === true
          ? compiler.all
          : compiler.necessary;

      // return from `compile` is an array of compilations
      return await compileMethod(config);
    })
  );

  // collect results
  // flatten the array and remove compilations without results
  const compilations = rawCompilations.reduce((a, compilationGroup) => {
    compilationGroup.forEach(compilation => {
      if (compilation.contracts.length > 0) {
        a = a.concat(compilation);<commit_msg>Don't set default when indexing into supported compilers object<commit_after>const debug = require("debug")("workflow-compile");
const fse = require("fs-extra");
const { prepareConfig } = require("./utils");
const { shimContract } = require("@truffle/compile-solidity/legacy/shims");
const {
  reportCompilationStarted,
  reportNothingToCompile,
  reportCompilationFinished
} = require("./reports");

const SUPPORTED_COMPILERS = {
  solc: require("@truffle/compile-solidity"),
  vyper: require("@truffle/compile-vyper"),
  external: require("@truffle/external-compile")
};

async function compile(config) {
  // determine compiler(s) to use
  //
  const compilers = config.compiler
    ? config.compiler === "none"
      ? []
      : [config.compiler]
    : Object.keys(config.compilers);

  // invoke compilers
  //
  const rawCompilations = await Promise.all(
    compilers.map(async name => {
      const compiler = SUPPORTED_COMPILERS[name];
      if (!compiler) throw new Error("Unsupported compiler: " + name);

      const compileMethod =
        config.all === true || config.compileAll === true
          ? compiler.all
          : compiler.necessary;

      // return from `compile` is an array of compilations
      return await compileMethod(config);
    })
  );

  // collect results
  // flatten the array and remove compilations without results
  const compilations = rawCompilations.reduce((a, compilationGroup) => {
    compilationGroup.forEach(compilation => {
      if (compilation.contracts.length > 0) {
        a = a.concat(compilation);
{'fraction_non_alphanumeric': 0.13109954456733897, 'fraction_numerical': 0.0006506180871828237, 'mean_word_length': 3.528718703976436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1346234', 'n_tokens_mistral': 899, 'n_tokens_neox': 890, 'n_words': 199}