UNPKG

965 Btext/coffeescriptView Raw
1getPath = require './get-path'
2{ normalize } = require 'path'
3
4module.exports = (
5 findPath
6 findMoule
7) ->
8
9 isLocal = (path) -> path[0] == '.'
10
11 getModulePaths = (base, conf, childCallers = []) ->
12 modules = conf.modules
13 parentConfigs = conf.parents || []
14 out = []
15 parentConfigs.forEach (p) ->
16 callers = childCallers.concat p.nodeModule
17 parentConf = findMoule base, p.configFile, callers
18 parentConfPath = findPath base, p.configFile, callers
19 out.push isConfig: true, isLocal: true, path: normalize parentConfPath
20 out = out.concat getModulePaths(base, parentConf, callers)
21 Object.keys(modules).map (key) ->
22 mod = modules[key]
23 registeredPath = getPath(mod)
24 fullPath = normalize findPath(base, registeredPath, childCallers)
25 out.push
26 key: key
27 path: fullPath
28 registeredPath: registeredPath
29 isLocal: isLocal(registeredPath)
30 module: mod
31
32 return out