-
-
Notifications
You must be signed in to change notification settings - Fork 37.3k
URL version of process.cwd() #49273
Copy link
Copy link
Closed as not planned
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.whatwg-urlIssues and PRs related to the WHATWG URL implementation.Issues and PRs related to the WHATWG URL implementation.
Description
Activity
Metadata
Metadata
Assignees
Labels
feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.whatwg-urlIssues and PRs related to the WHATWG URL implementation.Issues and PRs related to the WHATWG URL implementation.
What is the problem this feature will solve?
Right now we don't have convenient way to get current working directory in URL form such as
file:///path/to/current/working/directory/.Having easy access to this form would allow to resolve local paths using WHATWG URL constructor, i.e.
new URL('../path/to/file', cwdURL), without need to importpathand worry about platform-specific separators.Getting this form in userspace is not very convenient:
What is the feature you are proposing to solve the problem?
URLinstances withfile:protocol inprocess.chdir(directory).process.cwdURL()that returnsURLinstance or string.resolve(...urls)method that would construct new absolute URL on top of cwd if all providedurlsare relative.url.resolve()is not vacant and has different behaviour, so it should have different name or place.Better naming suggestions are very welcome.
What alternatives have you considered?
file:protocol that would resolve relativepathnameagainst cwd instead of root, i.e.: