()
| 64 | } |
| 65 | |
| 66 | export function resolve() { |
| 67 | var resolvedPath = ''; |
| 68 | var resolvedAbsolute = false; |
| 69 | var cwd; |
| 70 | |
| 71 | for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { |
| 72 | var path; |
| 73 | if (i >= 0) |
| 74 | path = arguments[i]; |
| 75 | else { |
| 76 | if (cwd === undefined) |
| 77 | // cwd = process.cwd(); |
| 78 | path = ''; |
| 79 | } |
| 80 | |
| 81 | // Skip empty entries |
| 82 | if (path.length === 0) { |
| 83 | continue; |
| 84 | } |
| 85 | |
| 86 | resolvedPath = path + '/' + resolvedPath; |
| 87 | resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/; |
| 88 | } |
| 89 | |
| 90 | // At this point the path should be resolved to a full absolute path, but |
| 91 | // handle relative paths to be safe (might happen when process.cwd() fails) |
| 92 | |
| 93 | // Normalize the path |
| 94 | resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); |
| 95 | |
| 96 | if (resolvedAbsolute) { |
| 97 | if (resolvedPath.length > 0) |
| 98 | return '/' + resolvedPath; |
| 99 | else |
| 100 | return '/'; |
| 101 | } else if (resolvedPath.length > 0) { |
| 102 | return resolvedPath; |
| 103 | } else { |
| 104 | return '.'; |
| 105 | } |
| 106 | } |
no test coverage detected