-
Notifications
You must be signed in to change notification settings - Fork 61
[cli_util] Add base directories #2130
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
Package publishing
Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation. |
PR HealthBreaking changes ✔️
Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. Coverage ✔️
This check for test coverage is informational (issues shown here will not fail the PR). API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
License Headers ✔️
All source files should start with a license header. Unrelated files missing license headers
|
fa12c44
to
ab74f0a
Compare
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.
LGTM
Let's also get a review from the code owner, though.
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.
Documentation changes only
I think this is great now. thanks for the ongoing discussions. |
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.
LGTM
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.
I'd consider computing all the paths in the constructor, once and for all, and not carry around the environment.
It also avoids any discussion about what happens if the environment map changes after the object has been created. (And, like, don't!)
Otherwise I'd feel silly creating and remembering the BaseDirectories
object for my tool, if it doesn't cache any computation anyway. I'd probably start caching the paths myself.
Alternatively, have the getters cache the results the first time they are computed, so you don't compute it anew the next time you look.
String? _runtimeHome;
String get runtimeHome => _runtimeHome ??= _baseDirectory(_BaseDir.runtime);
}; | ||
|
||
String _baseDirectoryMacOs(_XdgBaseDirectoryType dir) => switch (dir) { | ||
_XdgBaseDirectoryType.config => |
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.
MacOS uses /
as separator, so a single 'Library/Preferences'
should work.
Then it can be stored on the enum value and this function can become => path.join(_home, dir._macOSDefaultPath);
.
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.
Then it can be stored on the enum value
Ditto, that mixes the OSes together, making the code less readable.
Add utilities for finding base directories on the host OS for CLI applications.
This follows the OS specs
%APPDATA%
and%LOCALAPPDATA%
.This PR incorporates https://gist.github.com/dcharkes/8029549b3a13055fbd70b019cae4f9bd and dart-archive/cli_util#94. (@4e554c4c would you please review this PR.)
This PR does not incorporate the executables directories as that requires an opinionated approach on how
PATH
modifications are handled. (The executables are either placed inside the data/state directories or symlinked in a directory that might already be on path.)For dart-lang/sdk#60922, we might standardize on a single directory inside the "state" directory.