<commit_before>'use strict'

require('./typedefs')

const path = require('path')
const __ = require('lodash')
const versiony = require('versiony')
const Promise = require('promise')
const cpExec = require('child_process').exec
const exec = Promise.denodeify(cpExec)

const utils = {

  /**
   * Get the Options from either the `.pr-bumper.json` file or the defaults
   * @returns {Options} the options object
   */
  getOptions () {
    let options = {}
    try {
      options = require(path.join(process.cwd(), '.pr-bumper.json'))
    } catch (e) {
      console.log('No .pr-bumper.json found, using defaults')
    }
    __.defaults(options, {
      repoSlugEnv: 'TRAVIS_REPO_SLUG',
      prEnv: 'TRAVIS_PULL_REQUEST',
      buildNumberEnv: 'TRAVIS_BUILD_NUMBER'
    })

    return options
  },

  /**
   * Use an Options object to generate the Config
   * @param {Options} [options] - the options for what environment variables to use
   * @returns {Config} the config object
   */
  getConfig (options) {
    options = options || this.getOptions()

    let owner = options.owner
    let repo = options.repo
    const slug = process.env[options.repoSlugEnv]
    let parts = ['', '']

    if (slug) {
      parts = slug.split('/')
    }

    if (!owner) {
      owner = parts[0]
    }

    if (!repo) {
      repo = parts[1]
    }

    return {
      owner,
      repo,
      isPr: process.env[options.prEnv] !== 'false',
      prNumber: options.prEnv,
      buildNumber: process.env[options.buildNumberEnv]
    }
  },

  /**
   * Make sure scope is one of 'patch', 'minor', 'major' (or their aliases)
   *
   * @param {String} scope - the scope to check<commit_msg>lookup env var<commit_after>'use strict'

require('./typedefs')

const path = require('path')
const __ = require('lodash')
const versiony = require('versiony')
const Promise = require('promise')
const cpExec = require('child_process').exec
const exec = Promise.denodeify(cpExec)

const utils = {

  /**
   * Get the Options from either the `.pr-bumper.json` file or the defaults
   * @returns {Options} the options object
   */
  getOptions () {
    let options = {}
    try {
      options = require(path.join(process.cwd(), '.pr-bumper.json'))
    } catch (e) {
      console.log('No .pr-bumper.json found, using defaults')
    }
    __.defaults(options, {
      repoSlugEnv: 'TRAVIS_REPO_SLUG',
      prEnv: 'TRAVIS_PULL_REQUEST',
      buildNumberEnv: 'TRAVIS_BUILD_NUMBER'
    })

    return options
  },

  /**
   * Use an Options object to generate the Config
   * @param {Options} [options] - the options for what environment variables to use
   * @returns {Config} the config object
   */
  getConfig (options) {
    options = options || this.getOptions()

    let owner = options.owner
    let repo = options.repo
    const slug = process.env[options.repoSlugEnv]
    let parts = ['', '']

    if (slug) {
      parts = slug.split('/')
    }

    if (!owner) {
      owner = parts[0]
    }

    if (!repo) {
      repo = parts[1]
    }

    return {
      owner,
      repo,
      isPr: process.env[options.prEnv] !== 'false',
      prNumber: process.env[options.prEnv],
      buildNumber: process.env[options.buildNumberEnv]
    }
  },

  /**
   * Make sure scope is one of 'patch', 'minor', 'major' (or their aliases)
   *
   * @param {String} scope - the scope to check
{'fraction_non_alphanumeric': 0.13701492537313434, 'fraction_numerical': 0.0011940298507462687, 'mean_word_length': 2.7150776053215075, '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': '6363213', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1066, 'n_words': 285}