* 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.
()
| 413 | * @returns {URL} The current working directory or the volume root if it cannot be determined. |
| 414 | */ |
| 415 | function 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 | |
| 437 | function getSystemErrorMessage(err) { |
| 438 | return lazyUv().getErrorMessage(err); |
no test coverage detected
searching dependent graphs…