<commit_before>const prependIgnite = require('./prependIgnite')
const { find } = require('ramda')
const path = require('path')

/**
 * Detects the type of install the user is requesting for this plugin.
 *
 * We check 3 different things:
 *
 *   1. a plugin which exists in one of the plugin override paths
 *   2. a plugin which lives in a relative or absolute path
 *   3. otherwise let npm hook us up
 *
 * @param  {object} context - an ignite context
 * @return {object}         - specs about the type of install
 */
function detectInstall(context) {
  // grab some gluegun goodies
  const { filesystem, parameters, ignite } = context

  // grab the plugin overrides
  const pluginOverrides = (ignite && ignite.pluginOverrides) || []

  /**
   * Is this a valid ignite plugin?
   *
   * @param  {string} candidate - The potential directory to check.
   * @return {boolean}          - True if this is valid; otherwise false.
   */
  const isValidIgnitePluginDirectory = candidate =>
    filesystem.exists(candidate) === 'dir' &&
    filesystem.exists(`${candidate}${path.sep}package.json`) === 'file'

  // the plugin we're trying to install
  let plugin = parameters.second

  // extract the package name and (optionally) version
  let packageName, packageVersion
  let regex = /((?:.+\/)?@?[^@]+)(?:@([^@]+))?/
  let result = regex.exec(plugin)

  if (!result) {
    throw new Error(`"${plugin}" is not a valid plugin`)
  }

  packageName = result[1]
  packageVersion = result[2] || null
  const isScoped = /@[^@/]+$/.test(packageName)
  console.log(`scoped? ${isScoped}`)

  // If a path, expand that path. If not, prepend with `ignite-*`.
  if (packageName.includes(path.sep) && !isScoped) {
    packageName = filesystem.path(packageName)
  } else if (!isScoped) {
    packageName = prependIgnite(packageName)
  }

  // do we have overrides?
  if (pluginOverrides.length > 0) {
    // look for the plugin into one of our override paths
    const foundPath = find(
      overridePath => isValidIgnitePluginDirectory(`${overridePath}${path.sep}${packageName}`),
      pluginOverrides
    )

    // did we find it?
    if (foundPath) {
      const path = `${foundPath}/${packageName}`
      return {
        directory: path,
        override: true,
        moduleName: filesystem.read(`${path}/package.json`, 'json').name,
        type: 'directory'
      }
    }
  }
<commit_msg>fix: Remove console.log (#1388 by @mlaco)<commit_after>const prependIgnite = require('./prependIgnite')
const { find } = require('ramda')
const path = require('path')

/**
 * Detects the type of install the user is requesting for this plugin.
 *
 * We check 3 different things:
 *
 *   1. a plugin which exists in one of the plugin override paths
 *   2. a plugin which lives in a relative or absolute path
 *   3. otherwise let npm hook us up
 *
 * @param  {object} context - an ignite context
 * @return {object}         - specs about the type of install
 */
function detectInstall(context) {
  // grab some gluegun goodies
  const { filesystem, parameters, ignite } = context

  // grab the plugin overrides
  const pluginOverrides = (ignite && ignite.pluginOverrides) || []

  /**
   * Is this a valid ignite plugin?
   *
   * @param  {string} candidate - The potential directory to check.
   * @return {boolean}          - True if this is valid; otherwise false.
   */
  const isValidIgnitePluginDirectory = candidate =>
    filesystem.exists(candidate) === 'dir' &&
    filesystem.exists(`${candidate}${path.sep}package.json`) === 'file'

  // the plugin we're trying to install
  let plugin = parameters.second

  // extract the package name and (optionally) version
  let packageName, packageVersion
  let regex = /((?:.+\/)?@?[^@]+)(?:@([^@]+))?/
  let result = regex.exec(plugin)

  if (!result) {
    throw new Error(`"${plugin}" is not a valid plugin`)
  }

  packageName = result[1]
  packageVersion = result[2] || null
  const isScoped = /@[^@/]+$/.test(packageName)

  // If a path, expand that path. If not, prepend with `ignite-*`.
  if (packageName.includes(path.sep) && !isScoped) {
    packageName = filesystem.path(packageName)
  } else if (!isScoped) {
    packageName = prependIgnite(packageName)
  }

  // do we have overrides?
  if (pluginOverrides.length > 0) {
    // look for the plugin into one of our override paths
    const foundPath = find(
      overridePath => isValidIgnitePluginDirectory(`${overridePath}${path.sep}${packageName}`),
      pluginOverrides
    )

    // did we find it?
    if (foundPath) {
      const path = `${foundPath}/${packageName}`
      return {
        directory: path,
        override: true,
        moduleName: filesystem.read(`${path}/package.json`, 'json').name,
        type: 'directory'
      }
    }
  }

{'fraction_non_alphanumeric': 0.13516922430103007, 'fraction_numerical': 0.0037838974143367668, 'mean_word_length': 3.0876288659793816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6926365', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1429, 'n_words': 455}