UNPKG

456 Btext/coffeescriptView Raw
1{ normalize } = require 'path'
2prependNodeModules = (v) -> [ 'node_modules', v ]
3concatRight = (a1, a2) -> a2.concat a1
4isLocalFile = (path) -> path[0] == '.'
5
6module.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 '/'