Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
add ansiSupported (#4)
Browse files Browse the repository at this point in the history
* add ansiSupported

* review comments
  • Loading branch information
goderbauer authored Mar 16, 2017
1 parent c5ecf6a commit 8ae6f90
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 1.1.0

* Added `ansiSupported`
* Bumped minimum Dart SDK version to 1.23.0-dev.9.0

#### 1.0.2

* Minor doc updates
Expand Down
3 changes: 3 additions & 0 deletions lib/src/interface/local_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ class LocalPlatform extends Platform {

@override
String get version => io.Platform.version;

@override
bool get ansiSupported => io.Platform.ansiSupported;
}
7 changes: 7 additions & 0 deletions lib/src/interface/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ abstract class Platform {
/// whitespace and other version and build details.
String get version;

/// When stdio is connected to a terminal, whether ANSI codes are supported.
///
/// This value is hard-coded to true, except on Windows where only more recent
/// versions of Windows 10 support the codes.
bool get ansiSupported;

/// Returns a JSON-encoded representation of this platform.
String toJson() {
return const JsonEncoder.withIndent(' ').convert(<String, dynamic>{
Expand All @@ -129,6 +135,7 @@ abstract class Platform {
'packageRoot': packageRoot,
'packageConfig': packageConfig,
'version': version,
'ansiSupported': ansiSupported,
});
}
}
8 changes: 7 additions & 1 deletion lib/src/testing/fake_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FakePlatform extends Platform {
this.packageRoot,
this.packageConfig,
this.version,
this.ansiSupported,
});

/// Creates a new [FakePlatform] with properties whose initial values mirror
Expand All @@ -41,7 +42,8 @@ class FakePlatform extends Platform {
executableArguments = new List<String>.from(platform.executableArguments),
packageRoot = platform.packageRoot,
packageConfig = platform.packageConfig,
version = platform.version;
version = platform.version,
ansiSupported = platform.ansiSupported;

/// Creates a new [FakePlatform] with properties extracted from the encoded
/// JSON string.
Expand All @@ -63,6 +65,7 @@ class FakePlatform extends Platform {
packageRoot : map['packageRoot'],
packageConfig : map['packageConfig'],
version : map['version'],
ansiSupported: map['ansiSupported'],
);
}

Expand Down Expand Up @@ -101,4 +104,7 @@ class FakePlatform extends Platform {

@override
String version;

@override
bool ansiSupported;
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: platform
version: 1.0.2
version: 1.1.0
authors:
- Todd Volkert <[email protected]>
description: A pluggable, mockable platform abstraction for Dart.
Expand All @@ -9,4 +9,4 @@ dev_dependencies:
test: ^0.12.10

environment:
sdk: '>=1.19.0 <2.0.0'
sdk: '>=1.23.0-dev.9.0 <2.0.0'

0 comments on commit 8ae6f90

Please sign in to comment.