Skip to content

Instantly share code, notes, and snippets.

@pmoelgaard
Created February 21, 2016 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmoelgaard/d17af9281cd0e8958fa2 to your computer and use it in GitHub Desktop.
Save pmoelgaard/d17af9281cd0e8958fa2 to your computer and use it in GitHub Desktop.
Hook Harvester - Early Version
/// <reference path='../../typings/tsd.d.ts' />
import path = require('path');
import async = require('async');
function ModuleDef(server:any, next:Function):void {
var glob:any = require("glob");
glob('local_modules/**/hooks/**/*.js', function (err:Error, hooks:Array<string>):void {
async.eachSeries(
hooks,
function (hook:string, hookCallback:Function):void {
var hookPath = path.join(__dirname, '../../', hook);
var hook:Function = require(hookPath);
hook(server, function (err:Error, hook:any):void {
console.log(hook);
hookCallback(err, hook);
});
},
function (err:Error):void {
next();
}
)
})
}
export = ModuleDef;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment