CityWebConsultants / Iris

Modular content management and web application framework built with Node.js and MongoDB
http://irisjs.org
Other
9 stars 7 forks source link

Expose iris object to parent calling file #394

Closed FilipNest closed 7 years ago

FilipNest commented 7 years ago

Instead of returning undefined, this makes the require("iris") function return a promise that resolves to the actual Iris object of the instance. This is done through re-requiring the file that called it (but stopping a feedback loop from developing).

This is potentially very powerful and might make Iris projects a lot easier to manage (especially the module system).

So you can do stuff like:


require("irisjs")({
  // Normal config
}).then(function (iris) {

  // Modules, hooks etc can all be defined and required here like a normal node.js project

})

The only new bit is the promise at the end. This pull request shouldn't break any existing code (fingers crossed).

Was planning to do this as part of a major version refactor of lots of core code but it's actually been quite simple to slot in.

Have a play with it. Thoughts and feedback welcome.