Skip to content

Commit

Permalink
Fix ambigious dartdoc version value when unspecified.
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos committed Feb 12, 2024
1 parent f20956e commit b678d98
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.22.1

- Fix: unspecified `--dartdoc-version` will use the latest version in an isolated
environment. To use the SDK's `dartdoc`, set the value to `sdk`.

## 0.22.0

- `ToolEnvironment`:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ Options:
--hosted Download and analyze a hosted package (from https://pub.dev).
--[no-]dartdoc Run dartdoc and score the package on documentation coverage.
(defaults to on)
--dartdoc-version The dartdoc version to use (otherwise the latest stable).
--dartdoc-version The dartdoc version to use: `sdk`, `latest` (default) or `<version constraint>`.
```
2 changes: 1 addition & 1 deletion bin/pana.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ final _parser = ArgParser()
)
..addOption(
'dartdoc-version',
help: 'The dartdoc version to use (otherwise the latest stable).',
help: 'The dartdoc version to use: `sdk`, `latest` (default) or `<version constraint>`.',
)
..addOption(
'resources-output',
Expand Down
27 changes: 12 additions & 15 deletions lib/src/sdk_env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,16 @@ class ToolEnvironment {
if (sdkDir != null) ...['--sdk-dir', sdkDir],
];

PanaProcessResult pr;

if (_dartdocVersion != null) {
if (_dartdocVersion == 'sdk') {
final command =
usesFlutter ? _flutterSdk._dartSdk.dartCmd : _dartSdk.dartCmd;
return await runConstrained(
[...command, 'doc', ...args],
workingDirectory: packageDir,
environment: _dartSdk.environment,
timeout: timeout,
);
} else {
if (!_globalDartdocActivated) {
await runConstrained(
[
Expand All @@ -464,7 +471,7 @@ class ToolEnvironment {
'global',
'activate',
'dartdoc',
_dartdocVersion!,
if (_dartdocVersion != null) _dartdocVersion!,
],
environment: {
..._dartSdk.environment,
Expand All @@ -475,24 +482,14 @@ class ToolEnvironment {
_globalDartdocActivated = true;
}
final command = usesFlutter ? _flutterSdk.flutterCmd : _dartSdk.dartCmd;
pr = await runConstrained(
return await runConstrained(
[...command, 'pub', 'global', 'run', 'dartdoc', ...args],
workingDirectory: packageDir,
environment:
usesFlutter ? _flutterSdk.environment : _dartSdk.environment,
timeout: timeout,
);
} else {
final command =
usesFlutter ? _flutterSdk._dartSdk.dartCmd : _dartSdk.dartCmd;
pr = await runConstrained(
[...command, 'doc', ...args],
workingDirectory: packageDir,
environment: _dartSdk.environment,
timeout: timeout,
);
}
return pr;
}

/// Removes the `dev_dependencies` from the `pubspec.yaml`,
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.0
version: 0.22.1
repository: https://github.com/dart-lang/pana
topics:
- tool
Expand Down
2 changes: 1 addition & 1 deletion test/goldens/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Options:
--hosted Download and analyze a hosted package (from https://pub.dev).
--[no-]dartdoc Run dartdoc and score the package on documentation coverage.
(defaults to on)
--dartdoc-version The dartdoc version to use (otherwise the latest stable).
--dartdoc-version The dartdoc version to use: `sdk`, `latest` (default) or `<version constraint>`.

0 comments on commit b678d98

Please sign in to comment.