Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.0.0
* Added `stdinSupportsAnsi` and `stdinSupportsAnsi`
* Removed `ansiSupported`

### 1.1.1

* Updated `LocalPlatform` to use new `dart.io` API for ansi color support queries
Expand Down
7 changes: 5 additions & 2 deletions lib/src/interface/local_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io' as io show Platform, stdin;
import 'dart:io' as io show Platform, stdin, stdout;

import 'platform.dart';

Expand Down Expand Up @@ -48,5 +48,8 @@ class LocalPlatform extends Platform {
String get version => io.Platform.version;

@override
bool get ansiSupported => io.stdin.supportsAnsiEscapes;
bool get stdinSupportsAnsi => io.stdin.supportsAnsiEscapes;

@override
bool get stdoutSupportsAnsi => io.stdout.supportsAnsiEscapes;
}
13 changes: 7 additions & 6 deletions lib/src/interface/platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ 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;
/// When stdin is connected to a terminal, whether ANSI codes are supported.
bool get stdinSupportsAnsi;

/// When stdout is connected to a terminal, whether ANSI codes are supported.
bool get stdoutSupportsAnsi;

/// Returns a JSON-encoded representation of this platform.
String toJson() {
Expand All @@ -135,7 +135,8 @@ abstract class Platform {
'packageRoot': packageRoot,
'packageConfig': packageConfig,
'version': version,
'ansiSupported': ansiSupported,
'stdinSupportsAnsi': stdinSupportsAnsi,
'stdoutSupportsAnsi': stdoutSupportsAnsi,
});
}
}
14 changes: 10 additions & 4 deletions lib/src/testing/fake_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class FakePlatform extends Platform {
this.packageRoot,
this.packageConfig,
this.version,
this.ansiSupported,
this.stdinSupportsAnsi,
this.stdoutSupportsAnsi,
});

/// Creates a new [FakePlatform] with properties whose initial values mirror
Expand All @@ -44,7 +45,8 @@ class FakePlatform extends Platform {
packageRoot = platform.packageRoot,
packageConfig = platform.packageConfig,
version = platform.version,
ansiSupported = platform.ansiSupported;
stdinSupportsAnsi = platform.stdinSupportsAnsi,
stdoutSupportsAnsi = platform.stdoutSupportsAnsi;

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

Expand Down Expand Up @@ -107,5 +110,8 @@ class FakePlatform extends Platform {
String version;

@override
bool ansiSupported;
bool stdinSupportsAnsi;

@override
bool stdoutSupportsAnsi;
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: platform
version: 1.1.1
version: 2.0.0
authors:
- Todd Volkert <tvolkert@google.com>
description: A pluggable, mockable platform abstraction for Dart.
Expand Down