Skip to content

Commit

Permalink
Allow inspectDir method to use a custom logger. (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Oct 24, 2024
1 parent 4af97f7 commit 7be4153
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.22.14

- Accept `logger` in `PackageAnalyzer.inspectDir` method.

## 0.22.13

- Pass-through for `formatter/page_width` in `analysis_options.yaml`.
Expand Down
23 changes: 16 additions & 7 deletions lib/src/package_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,23 @@ class PackageAnalyzer {
}, logger: logger);
}

Future<Summary> inspectDir(String packageDir, {InspectOptions? options}) {
Future<Summary> inspectDir(
String packageDir, {
InspectOptions? options,
Logger? logger,
}) {
final sharedContext = _createSharedContext(options: options);
return withTempDir((tempDir) async {
final rootDir = await _detectGitRoot(packageDir) ?? packageDir;
await copyDir(rootDir, tempDir);
final relativeDir = path.relative(packageDir, from: rootDir);
return await _inspect(sharedContext, path.join(tempDir, relativeDir));
});
return withLogger(
logger: logger,
() async {
return withTempDir((tempDir) async {
final rootDir = await _detectGitRoot(packageDir) ?? packageDir;
await copyDir(rootDir, tempDir);
final relativeDir = path.relative(packageDir, from: rootDir);
return await _inspect(sharedContext, path.join(tempDir, relativeDir));
});
},
);
}

SharedAnalysisContext _createSharedContext({
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pana
description: PAckage aNAlyzer - produce a report summarizing the health and quality of a Dart package.
version: 0.22.13
version: 0.22.14-dev
repository: https://github.com/dart-lang/pana
topics:
- tool
Expand Down

0 comments on commit 7be4153

Please sign in to comment.