Don't cache result for homeDirPath. (#27873)

This commit is contained in:
KyleWong 2019-02-14 16:08:26 +08:00 committed by GitHub
parent da5c97c3ef
commit e99c881f8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,16 +7,14 @@ import 'platform.dart';
/// Return the absolute path of the user's home directory
String get homeDirPath {
if (_homeDirPath == null) {
_homeDirPath = platform.isWindows
? platform.environment['USERPROFILE']
: platform.environment['HOME'];
if (_homeDirPath != null)
_homeDirPath = fs.path.absolute(_homeDirPath);
String path = platform.isWindows
? platform.environment['USERPROFILE']
: platform.environment['HOME'];
if (path != null) {
path = fs.path.absolute(path);
}
return _homeDirPath;
return path;
}
String _homeDirPath;
/// Throw a specialized exception for expected situations
/// where the tool should exit with a clear message to the user