mariocasciaro / scatter

IoC container and out-of-the-box extensibility for Node.js applications
MIT License
154 stars 14 forks source link

Support of relative "paths" in scatter.load() #28

Open k7sleeper opened 9 years ago

k7sleeper commented 9 years ago

It would be useful if Scatter's load method as well supports relative module "paths" as the module dependency specification already does.

It should be possible to write

scatter.load("./web-server/index").then (web_srv) ->
  web_srv.setUp appConfig.webServer

instead of

mod_ns = ''
i = scatter.module.name.lastIndexOf '/'
if i >= 0
  mod_ns = scatter.module.name[0..i]

... and later ...

scatter.load("#{mod_ns}web-server/index").then (web_srv) ->
  web_srv.setUp appConfig.webServer
mariocasciaro commented 9 years ago

That would be tough because we need a way to know the location from where load() is called. However, if you call load from a container injected as dependency (using container!) it should work.

k7sleeper commented 9 years ago

Unfortunately, it's not working!

In the code above scatter is injected using container!.