Skip to content

Commit

Permalink
feat: Enhance Ansiconsole to detect no color settings
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Jan 26, 2023
1 parent 5ba7479 commit 8faa39d
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,26 @@ import org.gradle.api.logging.configuration.ConsoleOutput
*/
@CompileStatic
class AnsiConsole implements Serializable {
private boolean plain
final boolean plain

AnsiConsole(Project project) {
this(project.gradle)
this(project.gradle, '')
}

AnsiConsole(Gradle gradle) {
this(gradle, '')
}

AnsiConsole(Project project, String appName) {
this(project.gradle, appName)
}

AnsiConsole(Gradle gradle, String appName) {
plain = gradle.startParameter.consoleOutput == ConsoleOutput.Plain ||
'plain'.equalsIgnoreCase(System.getProperty('org.gradle.console'))
'plain'.equalsIgnoreCase(System.getProperty('org.gradle.console')) ||
System.getenv().containsKey('NO_COLOR') ||
(appName && System.getenv().containsKey(appName.toUpperCase(Locale.ENGLISH) + '_NO_COLOR')) ||
System.getenv().get('TERM') == 'dumb'
}

String black(CharSequence s) {
Expand Down

0 comments on commit 8faa39d

Please sign in to comment.