grantPreviewExample function
- Directory? from,
The example text of 07 9.3: the first fenced block between the language-check markers
after the heading ### 9.3 of docs/spec/07-permissions.md of the repository that holds
from (default: the working directory). Without such a repository (an app under test in
the macOS app sandbox) it reads the copy compiled into the fake
(contract_documents.g.dart, docs/DECISIONS.md D-M4-27-7).
Throws a StateError when the chapter has no marked example.
Implementation
String grantPreviewExample({Directory? from}) {
var dir = (from ?? Directory.current).absolute;
while (true) {
final file = File('${dir.path}/docs/spec/07-permissions.md');
if (file.existsSync()) return _example(file.readAsStringSync());
if (dir.parent.path == dir.path) {
return _example(embeddedPermissionsChapter());
}
dir = dir.parent;
}
}