Skip to content

Commit

Permalink
Prepare File.openRead for Dart 2.5 (#63)
Browse files Browse the repository at this point in the history
* Prepare File.openRead for Dart 2.5

* Updated changelog

* PR review fixes; disabled DDC in tests as it fails with Dart 2.5-dev
  • Loading branch information
pulyaevskiy authored Jul 14, 2019
1 parent 359f41d commit 1228725
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion node_io/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## 1.0.1+2

- More preparation for Uint8List SDK breaking change (dart-lang/sdk#36900).
See #61 for details.
See #61 and #63 for details.

## 1.0.1+1

Expand Down
10 changes: 5 additions & 5 deletions node_io/lib/src/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import 'package:node_interop/util.dart';
import 'file_system_entity.dart';
import 'streams.dart';

class _ReadStream extends ReadableStream<List<int>> {
class _ReadStream extends ReadableStream<Uint8List> {
_ReadStream(ReadStream nativeStream)
: super(nativeStream, convert: (chunk) => new List.unmodifiable(chunk));
: super(nativeStream, convert: (chunk) => new Uint8List.fromList(chunk));
}

class _WriteStream extends NodeIOSink {
Expand Down Expand Up @@ -259,7 +259,7 @@ class File extends FileSystemEntity implements io.File {
_RandomAccessFile.open(path, mode);

@override
Stream<List<int>> openRead([int start, int end]) {
Stream<Uint8List> openRead([int start, int end]) {
var options = new ReadStreamOptions();
if (start != null) options.start = start;
if (end != null) options.end = end;
Expand Down Expand Up @@ -295,8 +295,8 @@ class File extends FileSystemEntity implements io.File {

@override
Future<List<String>> readAsLines({Encoding encoding: utf8}) {
return openRead()
.transform(encoding.decoder)
return encoding.decoder
.bind(openRead())
.transform(new LineSplitter())
.toList();
}
Expand Down
5 changes: 3 additions & 2 deletions tool/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ if [ -f "package.json" ]; then
fi

if [ "$2" = "node" ]; then
echo "> pub run build_runner test (dartdevc) ============================="
pub run build_runner test --output=build/ -- -r expanded
# ddc disabled as tests are failing with dart 2.5-dev
# echo "> pub run build_runner test (dartdevc) ============================="
# pub run build_runner test --output=build/ -- -r expanded

echo "> pub run test (dart2js) ==========================================="
if [ -f "test/all_test.dart" ]; then
Expand Down

0 comments on commit 1228725

Please sign in to comment.