Skip to content

Instantly share code, notes, and snippets.

@alfg
Created October 26, 2015 17:36
Show Gist options
  • Save alfg/95ca60fcb9cd59973972 to your computer and use it in GitHub Desktop.
Save alfg/95ca60fcb9cd59973972 to your computer and use it in GitHub Desktop.
Module loader snippet for Node.js.
// Loads all modules in tasks directory.
require('fs')
.readdirSync(__dirname + '/tasks').forEach(function(file) {
if (file.match(/\.js$/) !== null) {
var name = file.replace('.js', '');
require('./tasks/' + name)(gulp, config);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment