Skip to content

Conversation

@FMorschel
Copy link
Contributor

Adding the option to replace ~ for the home directory in paths that use backslashes.

Also, making clearer that only the noted substitutions are allowed and everything else will be left in the path as-is.

@DanTup
Copy link
Member

DanTup commented Jul 30, 2024

Thanks!

@DanTup DanTup added this to the v3.94.0 milestone Jul 30, 2024
@DanTup
Copy link
Member

DanTup commented Jul 30, 2024

Hmm, while checking if we had tests for this, I found this comment:

// We always use forward slashes for home-dir-relative paths, even on Windows.
assert.equal(homeRelativePath(path.join(os.homedir(), "foo", "bar")), "~/foo/bar");

Which led me to this:

return path.join("~", path.relative(homedir, p)).replace(/\\/g, "/");

I think the reasoning here was that we want to be able to translate in both directions (so we can shorten display paths to use ~ when they're in the home dir), and in order to support teams that might want to commit the SDK paths (if they have a standard location for them, possibly to pin multiple versions), it would be better if the format was fixed across platforms.

So, I think it would be better to revert the change to support \ and instead note in the docs that ~ can be used for home directory, but the path should always use format slashes even on Windows (~/flutter/).

@FMorschel
Copy link
Contributor Author

Alright, will do that. Missed those tests.

Taking into consideration
/src/test/dart/util.test.ts line 248

Test:
homeRelativePath -> handles home dir
@DanTup DanTup merged commit 0f4dea8 into Dart-Code:master Jul 30, 2024
@DanTup DanTup changed the title Fix resolvePaths to handle Windows paths with backslashes Update settings descriptions to note substituion of ~ for homedir Jul 30, 2024
@DanTup
Copy link
Member

DanTup commented Jul 30, 2024

Thanks!

@FMorschel FMorschel deleted the home-with-backslashes branch July 30, 2024 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants