<commit_before>var assert = require('assert')
var path = require('path')

var createCertbot = require('certbot-wrapper')

module.exports = function createCert (config) {
  assert.equal(typeof config, 'object', 'cert: options object is required')
  assert.equal(typeof config.letsEncryptDir, 'string', 'cert: options.letsEncryptDir string is required')
  assert.equal(typeof config.letsEncryptChallengeDir, 'string', 'cert: options.letsEncryptChallengeDir string is required')
  config.cmd = config.cmd || 'certbot-auto'

  var cert = {}
  var certbot = createCertbot(config)

  cert.create = function createCert (options, callback) {
    assert.equal(typeof options, 'object', 'cert.create: options object is required')

    if (config.requestCerts === false) return callback()

    var opts = {
      args: {
        text: true,
        quiet: true,
        noSelfUpgrade: true,
        agreeTos: true,
        webroot: true,
        w: config.letsEncryptChallengeDir,
        domains: options.domain,
        email: options.email || '<EMAIL>',
        configDir: path.join(config.letsEncryptDir, 'config'),
        logsDir: path.join(config.letsEncryptDir, 'logs'),
        workDir: path.join(config.letsEncryptDir, 'work')
      }
    }

    if (config.debug) opts.args.staging = true
    certbot.certonly(opts, callback)
  }

  // cert.renew = function renew (options, callback) {
  //   var domain = options.domain
  //   var email = options.email || '<EMAIL>'
  //
  //   letsencrypt.getCert({
  //     url: url,
  //     email: email,
  //     domains: [options.domain],
  //     challenge: function challenge (domain, challengepath, data, done) {
  //       var challengeDir = path.join(config.dirs.sitesDir, 'html', domain, '.well-known', 'acme-challenge')
  //       var filename = challengepath.split('/acme-challenge/')[1]
  //
  //       mkdirp(challengeDir, function () {
  //         fs.writeFile(path.join(challengeDir, filename), data, function (err) {
  //           if (err) return done(err)
  //           done()
  //         })
  //       })
  //     },<commit_msg>use webrootPath<commit_after>var assert = require('assert')
var path = require('path')

var createCertbot = require('certbot-wrapper')

module.exports = function createCert (config) {
  assert.equal(typeof config, 'object', 'cert: options object is required')
  assert.equal(typeof config.letsEncryptDir, 'string', 'cert: options.letsEncryptDir string is required')
  assert.equal(typeof config.letsEncryptChallengeDir, 'string', 'cert: options.letsEncryptChallengeDir string is required')
  config.cmd = config.cmd || 'certbot-auto'

  var cert = {}
  var certbot = createCertbot(config)

  cert.create = function createCert (options, callback) {
    assert.equal(typeof options, 'object', 'cert.create: options object is required')

    if (config.requestCerts === false) return callback()

    var opts = {
      args: {
        text: true,
        quiet: true,
        noSelfUpgrade: true,
        agreeTos: true,
        webroot: true,
        webrootPath: config.letsEncryptChallengeDir,
        domains: options.domain,
        email: options.email || '<EMAIL>',
        configDir: path.join(config.letsEncryptDir, 'config'),
        logsDir: path.join(config.letsEncryptDir, 'logs'),
        workDir: path.join(config.letsEncryptDir, 'work')
      }
    }

    if (config.debug) opts.args.staging = true
    certbot.certonly(opts, callback)
  }

  // cert.renew = function renew (options, callback) {
  //   var domain = options.domain
  //   var email = options.email || '<EMAIL>'
  //
  //   letsencrypt.getCert({
  //     url: url,
  //     email: email,
  //     domains: [options.domain],
  //     challenge: function challenge (domain, challengepath, data, done) {
  //       var challengeDir = path.join(config.dirs.sitesDir, 'html', domain, '.well-known', 'acme-challenge')
  //       var filename = challengepath.split('/acme-challenge/')[1]
  //
  //       mkdirp(challengeDir, function () {
  //         fs.writeFile(path.join(challengeDir, filename), data, function (err) {
  //           if (err) return done(err)
  //           done()
  //         })
  //       })
  //     },
{'fraction_non_alphanumeric': 0.14149139579349904, 'fraction_numerical': 0.0004780114722753346, 'mean_word_length': 2.7634892086330933, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2581432', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1259, 'n_words': 293}