<commit_before>module.exports = function(contract, args, deployer) {
  return function() {
    var prefix = "Deploying ";
    if (contract.isDeployed()) {
      prefix = "Replacing ";
    }

    deployer.logger.log(prefix + contract.contract_name + "...");

    // Evaluate any arguments if they're promises
    return Promise.all(args).then(function(new_args) {
      return contract.new.apply(contract, new_args);
    }).then(function(instance) {
      deployer.logger.log(contract.contract_name + ": " + instance.address);
      contract.address = instance.address;
    });
  };
};<commit_msg>Add `overwrite` option to `.deploy()`; will detect if there’s a deployed version regardless of whether or not its been deployed (good for package management).<commit_after>module.exports = function(contract, args, deployer) {
  return function() {
    var should_deploy = true;

    // First detect the network to see if it's deployed.
    return contract.detectNetwork().then(function() {
      // Evaluate any arguments if they're promises (we need to do this in all cases to maintain consistency)
      return Promise.all(args)
    }).then(function(new_args) {
      // Check the last argument. If it's an object that tells us not to overwrite, then lets not.
      if (new_args.length > 0) {
        var last_arg = new_args[new_args.length - 1];
        if (typeof last_arg == "object" && last_arg.overwrite === false && contract.isDeployed()) {
          should_deploy = false;
        }
        delete last_arg.overwrite;
      }

      if (should_deploy == true) {
        var prefix = "Deploying ";
        if (contract.isDeployed()) {
          prefix = "Replacing ";
        }
        deployer.logger.log(prefix + contract.contract_name + "...");
        return contract.new.apply(contract, new_args);
      } else {
        return contract.deployed();
      }
    }).then(function(instance) {
      if (should_deploy == true) {
        deployer.logger.log(contract.contract_name + ": " + instance.address);
      } else {
        deployer.logger.log("Didn't deploy " + contract.contract_name + "; using " + instance.address);
      }

      // Ensure the address is set on the contract.
      contract.address = instance.address;
    });
  };
};
{'fraction_non_alphanumeric': 0.1269982238010657, 'fraction_numerical': 0.0008880994671403197, 'mean_word_length': 2.7487520798668883, 'pattern_counts': {'":': 2, '<': 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': '6194482', 'n_tokens_mistral': 652, 'n_tokens_neox': 633, 'n_words': 169}