Skip to content

Commit 09e05d1

Browse files
authored
Cache the current working directory (#2641)
1 parent bd11290 commit 09e05d1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/src/dartdoc_options.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ class _OptionValueWithContext<T> {
545545
/// built in to these classes so that file existence can be verified, types
546546
/// constrained, and defaults provided.
547547
///
548+
/// This class caches the current working directory from the [ResourceProvider];
549+
/// do not attempt to change it during the life of an instance.
550+
///
548551
/// Use via implementations [DartdocOptionSet], [DartdocOptionArgFile],
549552
/// [DartdocOptionArgOnly], and [DartdocOptionFileOnly].
550553
abstract class DartdocOption<T> {
@@ -727,10 +730,13 @@ abstract class DartdocOption<T> {
727730
/// Calls [valueAt] with the working directory at the start of the program.
728731
T valueAtCurrent() => valueAt(_directoryCurrent);
729732

733+
Folder __directoryCurrent;
730734
Folder get _directoryCurrent =>
731-
resourceProvider.getFolder(resourceProvider.pathContext.current);
735+
__directoryCurrent ??= resourceProvider.getFolder(_directoryCurrentPath);
732736

733-
String get _directoryCurrentPath => resourceProvider.pathContext.current;
737+
String __directoryCurrentPath;
738+
String get _directoryCurrentPath =>
739+
__directoryCurrentPath ??= resourceProvider.pathContext.current;
734740

735741
/// Calls [valueAt] on the directory this element is defined in.
736742
T valueAtElement(Element element) =>

0 commit comments

Comments
 (0)