How to use requireindex - 2 common examples

To help you get started, we’ve selected a few requireindex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github umijs / umi / packages / umi-build-dev / src / UserConfig.js View on Github external
initConfigPlugins() {
    const map = requireindex(join(__dirname, 'getConfig/configPlugins'));
    let plugins = Object.keys(map)
      .filter(key => !key.includes('.test.'))
      .map(key => {
        return map[key].default;
      });
    plugins = this.service.applyPlugins('_registerConfig', {
      initialValue: plugins,
    });
    this.plugins = plugins.map(p => p(this));
  }
github umijs / umi / packages / umi-build-dev / src / getConfig / index.js View on Github external
import { existsSync } from 'fs';
import { join } from 'path';
import { clearConsole } from 'af-webpack/react-dev-utils';
import chalk from 'chalk';
import isEqual from 'lodash.isequal';
import didyoumean from 'didyoumean';
import requireindex from 'requireindex';
import { CONFIG_FILES } from '../constants';
import { watch, unwatch } from './watch';
import { setConfig } from '../createRouteMiddleware';

const pluginsMap = requireindex(join(__dirname, './configPlugins'));
const plugins = Object.keys(pluginsMap).map(key => {
  return pluginsMap[key].default();
});
let devServer = null;

function printError(messages) {
  if (devServer) {
    devServer.sockWrite(
      devServer.sockets,
      'errors',
      typeof messages === 'string' ? [messages] : messages,
    );
  }
}

function printWarn(messages) {

requireindex

Write minimal node index.js files that require and export siblings by file basename

MIT
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis

Popular requireindex functions