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

Explicitly type Stream argument as List<int> #56

Merged
merged 2 commits into from
Jul 6, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.0

* Update internal type annotations for compatibility with [dart-lang/sdk#52801].

[dart-lang/sdk#52801]: https://github.com/dart-lang/sdk/issues/52801

## 0.3.2

* Declare support for Dart 3.
Expand Down
3 changes: 2 additions & 1 deletion lib/src/extensions/line_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import '../util.dart';
/// (as commonly emitted by a shell script).
extension LineStreamExtensions on Stream<String> {
/// Converts this to a byte stream with newlines baked in.
Stream<List<int>> get bytes => map((line) => utf8.encode("$line\n"));
Stream<List<int>> get bytes =>
map<List<int>>((line) => utf8.encode("$line\n"));

/// Pipes [this] into [script]'s [stdin] with newlines baked in.
///
Expand Down
2 changes: 1 addition & 1 deletion lib/src/script.dart
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class Script {
Script.fromByteTransformer(
StreamTransformer.fromBind((stream) => stream.lines
.transform(transformer)
.map((line) => utf8.encode("$line\n"))),
.map<List<int>>((line) => utf8.encode("$line\n"))),
name: name ?? transformer.toString());

/// Creates a [Script] from a function that maps strings to strings.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cli_script
version: 0.3.2
version: 1.0.0
description:
Write scripts that call subprocesses with the ease of shell scripting and the
power of Dart.
Expand Down
6 changes: 3 additions & 3 deletions test/pipe_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ void main() {
group("pipes in", () {
group("a byte stream", () {
test("without errors", () {
var pipeline =
Stream.fromIterable([utf8.encode("foo"), utf8.encode("bar")]) |
mainScript("stdin.pipe(stdout);");
var pipeline = Stream<List<int>>.fromIterable(
[utf8.encode("foo"), utf8.encode("bar")]) |
mainScript("stdin.pipe(stdout);");
expect(pipeline.stdout.lines, emitsInOrder(["foobar", emitsDone]));
});

Expand Down