()
| 386 | let resolvedPath = "" |
| 387 | let resolvedAbsolute = false |
| 388 | let cwd: string | undefined = undefined |
| 389 | |
| 390 | for (let i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { |
| 391 | let path: string |
| 392 | if (i >= 0) { |
| 393 | path = arguments[i] |
| 394 | } else { |
| 395 | const process = (globalThis as any).process |
| 396 | if ( |
| 397 | cwd === undefined && "process" in globalThis && |
| 398 | typeof process === "object" && |
| 399 | process !== null && |
| 400 | typeof process.cwd === "function" |
| 401 | ) { |
| 402 | cwd = process.cwd() |
| 403 | } |
| 404 | path = cwd! |
| 405 | } |
| 406 | |
| 407 | // Skip empty entries |
| 408 | if (path.length === 0) { |
| 409 | continue |
| 410 | } |
| 411 | |
| 412 | resolvedPath = path + "/" + resolvedPath |
| 413 | resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/ |
| 414 | } |
| 415 | |
| 416 | // At this point the path should be resolved to a full absolute path, but |
| 417 | // handle relative paths to be safe (might happen when process.cwd() fails) |
| 418 | |
| 419 | // Normalize the path |
| 420 | resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute) |
| 421 | |
| 422 | if (resolvedAbsolute) { |
| 423 | if (resolvedPath.length > 0) { |
| 424 | return "/" + resolvedPath |
| 425 | } else { |
| 426 | return "/" |
| 427 | } |
| 428 | } else if (resolvedPath.length > 0) { |
| 429 | return resolvedPath |
| 430 | } else { |
| 431 | return "." |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | const CHAR_FORWARD_SLASH = 47 |
| 436 | |
| 437 | function toFileUrl(filepath: string) { |
| 438 | const outURL = new URL("file://") |
| 439 | let resolved = resolve(filepath) |
searching dependent graphs…