<commit_before>import { Given } from 'cucumber'
import fs from 'fs-extra'
import mkdirp from 'mkdirp'
import path from 'path'
import { cp } from 'shelljs'

Given('a broken file {string}', function(filePath) {
  const subdir = path.dirname(filePath)
  if (subdir !== '.') {
    mkdirp.sync(path.join(this.rootDir, subdir))
  }
  fs.writeFileSync(
    path.join(this.rootDir, filePath),
    `
      <a href="missing">
      </a>
      `
  )
})

Given('a runnable file {string}', function(filePath) {
  const subdir = path.dirname(filePath)
  if (subdir !== '.') {
    const subdirPath = path.join(this.rootDir, subdir)
    if (!fs.existsSync(subdirPath)) {
      fs.mkdirSync(subdirPath)
    }
  }
  fs.writeFileSync(
    path.join(this.rootDir, filePath),
    '<a textrun="verify-workspace-contains-directory">`.`</a>'
  )
})

Given(
  'I am in a directory that contains documentation without a configuration file',
  function() {
    fs.writeFileSync(
      path.join(this.rootDir, '1.md'),
      `<code textrun="cd">.</code>`
    )
  }
)

Given('I am in a directory that contains the {string} example', function(
  exampleName
) {
  fs.copySync(path.join('documentation', 'examples', exampleName), this.rootDir)
})

Given(
  'I am in a directory that contains the {string} example with the configuration file:',
  function(exampleName, configFileContent) {
    fs.copySync(
      path.join('documentation', 'examples', exampleName),
      this.rootDir
    )
    fs.writeFileSync(path.join(this.rootDir, 'text-run.yml'), configFileContent)
  }
)

Given(
  /^I am in a directory that contains the "([^"]*)" example(?: without a configuration file)$/,
  function(exampleName) {
    fs.copySync(
      path.join('documentation', 'examples', exampleName),
      this.rootDir
    )
  }
)

// Given("my documentation is starting the {string} example", function(example) {
//   fs.writeFileSync(
//     path.join(this.rootDir, "0.md"),
//     `
//     <a textrun="start-console-command">
//       \`\`\`
//       node ${path.join(
//         __dirname,
//         "..",
//         "..",
//         "documentation",
//         "examples",
//         "long-running",
//         "server.js"
//       )}
//       \`\`\`
//       </a>
//       `
//   )
// })

Given('my source code contains the directory {string}', function(dirName) {<commit_msg>Remove old code (#550)<commit_after>import { Given } from 'cucumber'
import fs from 'fs-extra'
import mkdirp from 'mkdirp'
import path from 'path'
import { cp } from 'shelljs'

Given('a broken file {string}', function(filePath) {
  const subdir = path.dirname(filePath)
  if (subdir !== '.') {
    mkdirp.sync(path.join(this.rootDir, subdir))
  }
  fs.writeFileSync(
    path.join(this.rootDir, filePath),
    `
      <a href="missing">
      </a>
      `
  )
})

Given('a runnable file {string}', function(filePath) {
  const subdir = path.dirname(filePath)
  if (subdir !== '.') {
    const subdirPath = path.join(this.rootDir, subdir)
    if (!fs.existsSync(subdirPath)) {
      fs.mkdirSync(subdirPath)
    }
  }
  fs.writeFileSync(
    path.join(this.rootDir, filePath),
    '<a textrun="verify-workspace-contains-directory">`.`</a>'
  )
})

Given(
  'I am in a directory that contains documentation without a configuration file',
  function() {
    fs.writeFileSync(
      path.join(this.rootDir, '1.md'),
      `<code textrun="cd">.</code>`
    )
  }
)

Given('I am in a directory that contains the {string} example', function(
  exampleName
) {
  fs.copySync(path.join('documentation', 'examples', exampleName), this.rootDir)
})

Given(
  'I am in a directory that contains the {string} example with the configuration file:',
  function(exampleName, configFileContent) {
    fs.copySync(
      path.join('documentation', 'examples', exampleName),
      this.rootDir
    )
    fs.writeFileSync(path.join(this.rootDir, 'text-run.yml'), configFileContent)
  }
)

Given(
  /^I am in a directory that contains the "([^"]*)" example(?: without a configuration file)$/,
  function(exampleName) {
    fs.copySync(
      path.join('documentation', 'examples', exampleName),
      this.rootDir
    )
  }
)

Given('my source code contains the directory {string}', function(dirName) {
{'fraction_non_alphanumeric': 0.16180308422301304, 'fraction_numerical': 0.0014234875444839859, 'mean_word_length': 3.0852713178294575, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4799908', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1398, 'n_words': 320}