text: 'use strict';
  
  const path = require('path');
  const globby = require('globby');
  const v = require('@mapbox/fusspot');
  const pascalCase = require('pascal-case');
  
  function buildIndex(inputPath, output) {
    const glob = path.join(inputPath, '**/*-test-cases.js');
    return globby(glob, { absolute: true }).then((itemPaths) => {
      const outputDir = path.dirname(output);
      const allItems = itemPaths.sort().map((itemPath) => {
        const itemBaseName = path.basename(itemPath, '.js');
        const kebabCaseName = itemBaseName.replace(/-test-cases$/, '');
        const pascalCaseName = pascalCase(kebabCaseName);
        return {
          title: pascalCaseName,
          path: './' + path.relative(outputDir, itemPath)
        };
      });
  
      return renderFile(allItems);
    });
  }
  
  function renderItem(item) {
    return `{ title: '${item.title}', cases: getTestCases(require('${item.path}')) }`;
  }
  
  function renderFile(allItems) {
    v.assert(
      v.arrayOf(
        v.shape({
          title: v.required(v.string),
          path: v.required(v.string)
        })
      )
    )(allItems);
  
    const itemStrings = allItems.map((obj) => {
      return renderItem(obj);
    });
  
    return `/* eslint-disable */
  'use strict';
  // DO NOT MODIFY DIRECTLY
  // This file is generated by a script in bin.
  
  function getTestCases(m) {
    if (m.testCases) {
      return m.testCases;
    }
    if (m.default && m.default.testCases) {
      return m.default.testCases;
    }
    throw new Error('Every test case module needs a testCases export.');
  }
  
  module.exports = [
    ${itemStrings.join(',\n  ')}
  ];
  `;
  }
  
  module.exports = buildIndex;
  