How to use require-directory - 3 common examples

To help you get started, we’ve selected a few require-directory 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 zephraph / postcss-remove-null / tests / index.js View on Github external
import test from 'tape';
import postcss from 'postcss';
import plugin from '../lib';
import { name } from '../package.json';
import requireDir from 'require-directory';
import forEach from 'lodash/collection/forEach';

let suites = requireDir(module);
let tests = [];

forEach(suites, (test, suite) => {
  tests = tests.concat(test.default.filter( test => test.message = `${suite}: ${test.message}`));
});

function process (css, options) {
  return postcss(plugin(options)).process(css).css;
}

test(name, t => {
  t.plan(tests.length);

  tests.forEach(test => {
    var options = test.options || {};
    t.equal(process(test.fixture, options), test.expected, test.message);
github Adaptech / nota / api / scripts / seed.js View on Github external
(async () => {
  try {
    await initializeServices(services);
    const seeds = requireDirectory(module, './seeds');
    const aggregates = {};
    for (let [key, seed] of Object.entries(seeds)) { await seed.default(services, aggregates); };
    process.exit(0);
  } catch (err) {
    logger.error(err);
    process.exit(1);
  }
})();
github zephraph / postcss-remove-null / lib / processors / index.js View on Github external
import requireDirectory from 'require-directory';
import contains from 'lodash/collection/contains';

let processors = requireDirectory(module);
let types = Object.keys(processors);

let trblTypes = processors.trbl.types;

export function process(css) {

  css.walkDecls( decl => {

    if (contains(decl.value, 'null')) {

      if (contains(types, decl.prop)) {
        processors[decl.prop].default(decl);
      }
      else if (contains(trblTypes, decl.prop)) {
        processors.trbl.default(decl);
      }

require-directory

Recursively iterates over specified directory, require()'ing each file, and returning a nested hash structure containing those modules.

MIT
Latest version published 9 years ago

Package Health Score

67 / 100
Full package analysis

Popular require-directory functions