(...paths: string[])
| 116 | |
| 117 | // path.resolve([from ...], to) |
| 118 | const resolve = function resolve(...paths: string[]) { |
| 119 | let resolvedPath = ''; |
| 120 | let resolvedAbsolute = false; |
| 121 | let cwd; |
| 122 | |
| 123 | for (let i = paths.length - 1; i >= -1 && !resolvedAbsolute; i--) { |
| 124 | let path; |
| 125 | if (i >= 0) { |
| 126 | path = paths[i]; |
| 127 | } else { |
| 128 | if (cwd === undefined) { |
| 129 | if (opts && typeof opts.cwd === 'function') { |
| 130 | cwd = opts.cwd(); |
| 131 | } else if (typeof process !== 'undefined' && typeof process.cwd === 'function') { |
| 132 | cwd = process.cwd(); |
| 133 | } else { |
| 134 | cwd = '/'; |
| 135 | } |
| 136 | } |
| 137 | path = cwd; |
| 138 | } |
| 139 | |
| 140 | assertPath(path); |
| 141 | |
| 142 | // Skip empty entries |
| 143 | if (path.length === 0) { |
| 144 | continue; |
| 145 | } |
| 146 | |
| 147 | resolvedPath = path + '/' + resolvedPath; |
| 148 | resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/; |
| 149 | } |
| 150 | |
| 151 | // At this point the path should be resolved to a full absolute path, but |
| 152 | // handle relative paths to be safe (might happen when process.cwd() fails) |
| 153 | |
| 154 | // Normalize the path |
| 155 | resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); |
| 156 | |
| 157 | if (resolvedAbsolute) { |
| 158 | if (resolvedPath.length > 0) { |
| 159 | return '/' + resolvedPath; |
| 160 | } else { |
| 161 | return '/'; |
| 162 | } |
| 163 | } else if (resolvedPath.length > 0) { |
| 164 | return resolvedPath; |
| 165 | } else { |
| 166 | return '.'; |
| 167 | } |
| 168 | }; |
| 169 | |
| 170 | const normalize = function normalize(path: string) { |
| 171 | assertPath(path); |
no test coverage detected
searching dependent graphs…