-
-
Notifications
You must be signed in to change notification settings - Fork 494
Support resolving paths starting with ~ under Unix and Windows
#3665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR extends tilde (~) path resolution support from macOS-only to all Unix-like systems and Windows. Previously, the code only resolved paths starting with ~ on Darwin (macOS), but now it works universally across platforms.
- Removed platform-specific check for
darwinto enable tilde expansion on all platforms - Updated comment to reflect support for both Unix and Windows path separators
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/util.ts | Removed macOS-specific platform check to enable tilde path resolution on Unix and Windows |
| CHANGELOG.md | Added entry documenting the new cross-platform tilde path resolution feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pathToResolve.indexOf("~") === 0 && | ||
| os.homedir() | ||
| ) { | ||
| // In case the user wants to use path like `~/.prettierrc` on unix or `~\.prettierrc` on windows |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The word 'unix' should be capitalized as 'Unix' to match the capitalization of 'Windows' in the same sentence.
| // In case the user wants to use path like `~/.prettierrc` on unix or `~\.prettierrc` on windows | |
| // In case the user wants to use path like `~/.prettierrc` on Unix or `~\.prettierrc` on windows |
| // In case the user wants to use path like `~/.prettierrc` on unix or `~\.prettierrc` on windows | ||
| if (pathToResolve.indexOf("~") === 0 && os.homedir()) { | ||
| return pathToResolve.replace(/^~(?=$|\/|\\)/, os.homedir()); |
Copilot
AI
Nov 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tilde path resolution logic now supports Windows in addition to Unix systems, but lacks test coverage. Consider adding unit tests to verify: (1) tilde expansion works with Unix-style paths (~/.prettierrc), (2) tilde expansion works with Windows-style paths (~\.prettierrc), (3) tilde is not expanded when it appears mid-path, and (4) behavior when os.homedir() is empty.
CHANGELOG.mdwith a summary of your changes