<commit_before>import plugin from '@start/plugin/src/'

export default (outDirRelative: string, ...flowArgs: string[]) =>
  plugin('flowGenerate', async ({ files, logFile }) => {
    const { default: path } = require('path')
    const { default: execa } = require('execa')

    const outDir = path.resolve(outDirRelative)
    const flowBinPath = path.resolve('node_modules/.bin/flow')

    const spawnOptions = {
      stripEof: false,
      env: {
        FORCE_COLOR: '1'
      }
    }

    return Promise.all(
      files.map((file) =>
        execa(
          'node',
          [flowBinPath, 'gen-flow-files', file.path, '--out-dir', outDir, ...flowArgs],
          spawnOptions
        ).then(() => {
          logFile(path.join(outDir, `${path.basename(file.path)}.flow`))

          return file
        })
      )
    )
  })
<commit_msg>🛠️ plugin-lib-flow-generate: get rid of `require`<commit_after>import plugin from '@start/plugin/src/'

export default (outDirRelative: string, ...flowArgs: string[]) =>
  plugin('flowGenerate', async ({ files, logFile }) => {
    const { default: path } = await import('path')
    const { default: execa } = await import('execa')

    const outDir = path.resolve(outDirRelative)
    const flowBinPath = path.resolve('node_modules/.bin/flow')

    const spawnOptions = {
      stripEof: false,
      env: {
        FORCE_COLOR: '1'
      }
    }

    return Promise.all(
      files.map((file) =>
        execa(
          'node',
          [flowBinPath, 'gen-flow-files', file.path, '--out-dir', outDir, ...flowArgs],
          spawnOptions
        ).then(() => {
          logFile(path.join(outDir, `${path.basename(file.path)}.flow`))

          return file
        })
      )
    )
  })

{'fraction_non_alphanumeric': 0.16147635524798154, 'fraction_numerical': 0.0011534025374855825, 'mean_word_length': 2.3047619047619046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5892033', 'n_tokens_mistral': 549, 'n_tokens_neox': 545, 'n_words': 111}