MCPcopy Index your code
hub / github.com/nodejs/node / getCWDURL

Function getCWDURL

lib/internal/util.js:415–435  ·  view source on GitHub ↗

* Get the current working directory while accounting for the possibility that it has been deleted. * `process.cwd()` can fail if the parent directory is deleted while the process runs. * @returns {URL} The current working directory or the volume root if it cannot be determined.

()

Source from the content-addressed store, hash-verified

413 * @returns {URL} The current working directory or the volume root if it cannot be determined.
414 */
415function getCWDURL() {
416 const { sep } = require('path');
417 const { pathToFileURL } = require('internal/url');
418
419 let cwd;
420
421 try {
422 // The implementation of `process.cwd()` already uses proper cache when it can.
423 // It's a relatively cheap call performance-wise for the most common use case.
424 cwd = process.cwd();
425 } catch {
426 cachedURL ??= pathToFileURL(sep);
427 }
428
429 if (cwd != null && cwd !== cachedCWD) {
430 cachedURL = pathToFileURL(cwd + sep);
431 cachedCWD = cwd;
432 }
433
434 return cachedURL;
435}
436
437function getSystemErrorMessage(err) {
438 return lazyUv().getErrorMessage(err);

Calls 2

pathToFileURLFunction · 0.70
requireFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…