How to use require-glob - 7 common examples

To help you get started, we’ve selected a few require-glob 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 shannonmoeller / gulp-hb / index.js View on Github external
var data = options.data,
		dataEach = options.dataEach,
		debug = options.debug,
		includeFile = options.file;

	// Default to `true`
	if (includeFile == null) {
		includeFile = true;
	}

	// Generate data
	if (data) {
		options.keygen = options.parseDataName;
		options.reducer = options.dataReducer;
		data = requireGlob.sync(data, options);
	}

	// Register helpers and partials
	registrar(hb.handlebars, options);

	// Stream it
	return through.obj(function (file, enc, cb) {
		var context, template,
			hbs = hb.handlebars;

		try {
			context = mixin({}, data);

			if (includeFile) {
				context.file = file;
			}
github shannonmoeller / handlebars-wax / index.js View on Github external
// Register helpers
	if (helpers) {
		options.keygen = options.parseHelperName || parseHelperName;
		options.reducer = options.helpersReducer || reducer.bind(options);

		helpers = requireGlob.sync(helpers, options);
		handlebars.registerHelper(helpers);
	}

	// Register partials
	if (partials) {
		options.keygen = options.parsePartialName || parsePartialName;
		options.reducer = options.partialsReducer || reducer.bind(options);

		partials = requireGlob.sync(partials, options);
		handlebars.registerPartial(partials);
	}

	return handlebars;
}
github shannonmoeller / handlebars-wax / index.js View on Github external
function registrar(handlebars, options) {
	options = options || {};

	var helpers = options.helpers,
		partials = options.partials;

	// Expose handlebars to custom reducers
	options.handlebars = handlebars;

	// Register helpers
	if (helpers) {
		options.keygen = options.parseHelperName || parseHelperName;
		options.reducer = options.helpersReducer || reducer.bind(options);

		helpers = requireGlob.sync(helpers, options);
		handlebars.registerHelper(helpers);
	}

	// Register partials
	if (partials) {
		options.keygen = options.parsePartialName || parsePartialName;
		options.reducer = options.partialsReducer || reducer.bind(options);

		partials = requireGlob.sync(partials, options);
		handlebars.registerPartial(partials);
	}

	return handlebars;
}
github shannonmoeller / handlebars-wax / index.js View on Github external
if (getTypeOf(value) === TYPE_FUNCTION) {
		value = value(options.handlebars, options);

		if (getTypeOf(value) === TYPE_OBJECT) {
			return value;
		}

		return {};
	}

	if (getTypeOf(value) === TYPE_OBJECT) {
		return reducer(options, {}, {exports: value});
	}

	return requireGlob.sync(value, options);
}
github thiagobustamante / typescript-rest / src / server / server.ts View on Github external
public static loadServices(router: express.Router, patterns: string | Array, baseDir?: string) {
        serverDebugger('Loading typescript-rest services %j. BaseDir: %s', patterns, baseDir);
        const importedTypes: Array = [];
        const requireGlob = require('require-glob');
        baseDir = baseDir || process.cwd();
        const loadedModules: Array = requireGlob.sync(patterns, {
            cwd: baseDir
        });

        _.values(loadedModules).forEach(serviceModule => {
            _.values(serviceModule)
                .filter((service: Function) => typeof service === 'function')
                .forEach((service: Function) => {
                    importedTypes.push(service);
                });
        });

        try {
            Server.buildServices(router, ...importedTypes);
        } catch (e) {
            serverDebugger('Error loading services for pattern: %j. Error: %o', patterns, e);
            serverDebugger('ImportedTypes: %o', importedTypes);
github bartsmykla / Chrome-Firefox-Opera-Edge-Safari-Extensions-Boilerplate-with-Hot-Module-Replacement / locales / en / index.js View on Github external
const requireGLob = require('require-glob');
const helpers = require('../../config/helpers');

const { flatten } = helpers;

module.exports = flatten(requireGLob.sync(['**/*.json']), {}, 'LOCALES');
github thiagobustamante / typescript-ioc / src / container-config.ts View on Github external
public static addSource(patterns: string | Array, baseDir?: string) {
        const requireGlob = require('require-glob');
        baseDir = baseDir || process.cwd();
        requireGlob.sync(patterns, {
            cwd: baseDir
        });
    }
}

require-glob

Require multiple modules using glob patterns. Supports exclusions.

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis

Popular require-glob functions