MCPcopy Create free account
hub / github.com/effect-app/libs / resolve

Function resolve

repos/effect/packages/effect/src/Path.ts:388–436  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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
435const CHAR_FORWARD_SLASH = 47
436
437function toFileUrl(filepath: string) {
438 const outURL = new URL("file://")
439 let resolved = resolve(filepath)

Callers 15

runtimePromiseFunction · 0.70
runtimePromiseFunction · 0.70
validateFunction · 0.70
runtimePromiseFunction · 0.70
toFileUrlFunction · 0.70
utils.tsFile · 0.50
suspense.test.tsFile · 0.50
settleFunction · 0.50
resolveJSDocApiSeeLinksFunction · 0.50
atomToPromiseFunction · 0.50

Calls 1

normalizeStringPosixFunction · 0.85

Tested by 1

settleFunction · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…