1 | { normalize } = require 'path'
|
2 | prependNodeModules = (v) -> [ 'node_modules', v ]
|
3 | concatRight = (a1, a2) -> a2.concat a1
|
4 | isLocalFile = (path) -> path[0] == '.'
|
5 |
|
6 | module.exports = (base, path, callers) ->
|
7 | if callers.length == 0 && isLocalFile(path)
|
8 | out = path
|
9 | else
|
10 | end = if isLocalFile path then path else prependNodeModules path
|
11 | out = callers.map(prependNodeModules).reduceRight(concatRight, end).join '/'
|
12 |
|
13 | normalize [ base, out ].join '/'
|