Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xdg_directories] Fix stdout encoding handling #277

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/xdg_directories/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.2.0-nullsafety.1] - Fix getUserDirectory

* Fixes a regression due to the stdoutEncoding change
in the null-safety migration.

## [0.2.0-nullsafety.0] - Migrated to null safety

* Migrated to null safety.
Expand Down
4 changes: 2 additions & 2 deletions packages/xdg_directories/lib/xdg_directories.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ Directory? getUserDirectory(String dirName) {
final ProcessResult result = _processManager.runSync(
<String>['xdg-user-dir', dirName],
includeParentEnvironment: true,
stdoutEncoding: Encoding.getByName('utf8') ?? systemEncoding,
stdoutEncoding: utf8,
);
final String path = utf8.decode(result.stdout).split('\n')[0];
final String path = result.stdout.split('\n')[0];
return Directory(path);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/xdg_directories/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: xdg_directories
description: A Dart package for reading XDG directory configuration information on Linux.
version: 0.2.0-nullsafety.0
version: 0.2.0-nullsafety.1
homepage: https://github.com/flutter/packages/tree/master/packages/xdg_directories

environment:
Expand Down
2 changes: 1 addition & 1 deletion packages/xdg_directories/test/xdg_directories_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,6 @@ class FakeProcessManager extends Fake implements ProcessManager {
Encoding stdoutEncoding = systemEncoding,
Encoding stderrEncoding = systemEncoding,
}) {
return ProcessResult(0, 0, expected[command[1]]!.codeUnits, <int>[]);
return ProcessResult(0, 0, expected[command[1]]!, '');
}
}