Skip to content

Commit 2dc6cf8

Browse files
committed
Remove force color.
1 parent 865f29b commit 2dc6cf8

File tree

3 files changed

+32
-54
lines changed

3 files changed

+32
-54
lines changed

jscomp/gentype/GenType.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
let processCmt cmt =
2-
Log_.Color.forceColor := true;
32
let config = Paths.readConfig ~namespace:(cmt |> Paths.findNameSpace) in
43
if !Debug.basic then Log_.item "Add %s\n" cmt;
54
cmt |> GenTypeMain.processCmtFile ~config

jscomp/gentype/Log_.ml

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
module Color = struct
2-
let color_enabled = lazy (Unix.isatty Unix.stdout)
3-
4-
let forceColor = ref false
5-
6-
let get_color_enabled () = !forceColor || Lazy.force color_enabled
7-
82
type color = Red | Yellow | Magenta | Cyan
9-
103
type style = FG of color | Bold | Dim
114

125
let code_of_style = function
@@ -19,11 +12,11 @@ module Color = struct
1912

2013
let style_of_stag s =
2114
match s with
22-
| Format.String_tag "error" -> [Bold; FG Red]
23-
| Format.String_tag "warning" -> [Bold; FG Magenta]
24-
| Format.String_tag "info" -> [Bold; FG Yellow]
25-
| Format.String_tag "dim" -> [Dim]
26-
| Format.String_tag "filename" -> [FG Cyan]
15+
| Format.String_tag "error" -> [ Bold; FG Red ]
16+
| Format.String_tag "warning" -> [ Bold; FG Magenta ]
17+
| Format.String_tag "info" -> [ Bold; FG Yellow ]
18+
| Format.String_tag "dim" -> [ Dim ]
19+
| Format.String_tag "filename" -> [ FG Cyan ]
2720
| _ -> []
2821

2922
let ansi_of_stag s =
@@ -35,10 +28,8 @@ module Color = struct
3528

3629
let color_functions =
3730
(({
38-
mark_open_stag =
39-
(fun s -> if get_color_enabled () then ansi_of_stag s else "");
40-
mark_close_stag =
41-
(fun _ -> if get_color_enabled () then reset_lit else "");
31+
mark_open_stag = (fun s -> ansi_of_stag s);
32+
mark_close_stag = (fun _ -> reset_lit);
4233
print_open_stag = (fun _ -> ());
4334
print_close_stag = (fun _ -> ());
4435
}
@@ -50,7 +41,6 @@ module Color = struct
5041
Format.pp_set_formatter_stag_functions Format.std_formatter color_functions
5142

5243
let error ppf s = Format.fprintf ppf "@{<error>%s@}" s [@@dead "Color.error"]
53-
5444
let info ppf s = Format.fprintf ppf "@{<info>%s@}" s
5545
end
5646

@@ -72,16 +62,16 @@ module Loc = struct
7262
| Some
7363
((start_line, start_line_start_char), (end_line, end_line_end_char))
7464
->
75-
if start_line = end_line then
76-
if start_line_start_char = end_line_end_char then
77-
Format.fprintf ppf ":@{<dim>%i:%i@}" start_line
78-
start_line_start_char
65+
if start_line = end_line then
66+
if start_line_start_char = end_line_end_char then
67+
Format.fprintf ppf ":@{<dim>%i:%i@}" start_line
68+
start_line_start_char
69+
else
70+
Format.fprintf ppf ":@{<dim>%i:%i-%i@}" start_line
71+
start_line_start_char end_line_end_char
7972
else
80-
Format.fprintf ppf ":@{<dim>%i:%i-%i@}" start_line
81-
start_line_start_char end_line_end_char
82-
else
83-
Format.fprintf ppf ":@{<dim>%i:%i-%i:%i@}" start_line
84-
start_line_start_char end_line end_line_end_char
73+
Format.fprintf ppf ":@{<dim>%i:%i-%i:%i@}" start_line
74+
start_line_start_char end_line end_line_end_char
8575
in
8676
Format.fprintf ppf "@{<filename>%a@}%a" print_filename file dim_loc
8777
normalizedRange

lib/4.06.1/whole_compiler.ml

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -235354,14 +235354,7 @@ module Log_
235354235354
= struct
235355235355
#1 "Log_.ml"
235356235356
module Color = struct
235357-
let color_enabled = lazy (Unix.isatty Unix.stdout)
235358-
235359-
let forceColor = ref false
235360-
235361-
let get_color_enabled () = !forceColor || Lazy.force color_enabled
235362-
235363235357
type color = Red | Yellow | Magenta | Cyan
235364-
235365235358
type style = FG of color | Bold | Dim
235366235359

235367235360
let code_of_style = function
@@ -235374,11 +235367,11 @@ module Color = struct
235374235367

235375235368
let style_of_stag s =
235376235369
match s with
235377-
| Format.String_tag "error" -> [Bold; FG Red]
235378-
| Format.String_tag "warning" -> [Bold; FG Magenta]
235379-
| Format.String_tag "info" -> [Bold; FG Yellow]
235380-
| Format.String_tag "dim" -> [Dim]
235381-
| Format.String_tag "filename" -> [FG Cyan]
235370+
| Format.String_tag "error" -> [ Bold; FG Red ]
235371+
| Format.String_tag "warning" -> [ Bold; FG Magenta ]
235372+
| Format.String_tag "info" -> [ Bold; FG Yellow ]
235373+
| Format.String_tag "dim" -> [ Dim ]
235374+
| Format.String_tag "filename" -> [ FG Cyan ]
235382235375
| _ -> []
235383235376

235384235377
let ansi_of_stag s =
@@ -235390,10 +235383,8 @@ module Color = struct
235390235383

235391235384
let color_functions =
235392235385
(({
235393-
mark_open_stag =
235394-
(fun s -> if get_color_enabled () then ansi_of_stag s else "");
235395-
mark_close_stag =
235396-
(fun _ -> if get_color_enabled () then reset_lit else "");
235386+
mark_open_stag = (fun s -> ansi_of_stag s);
235387+
mark_close_stag = (fun _ -> reset_lit);
235397235388
print_open_stag = (fun _ -> ());
235398235389
print_close_stag = (fun _ -> ());
235399235390
}
@@ -235405,7 +235396,6 @@ module Color = struct
235405235396
Format.pp_set_formatter_stag_functions Format.std_formatter color_functions
235406235397

235407235398
let error ppf s = Format.fprintf ppf "@{<error>%s@}" s [@@dead "Color.error"]
235408-
235409235399
let info ppf s = Format.fprintf ppf "@{<info>%s@}" s
235410235400
end
235411235401

@@ -235427,16 +235417,16 @@ module Loc = struct
235427235417
| Some
235428235418
((start_line, start_line_start_char), (end_line, end_line_end_char))
235429235419
->
235430-
if start_line = end_line then
235431-
if start_line_start_char = end_line_end_char then
235432-
Format.fprintf ppf ":@{<dim>%i:%i@}" start_line
235433-
start_line_start_char
235420+
if start_line = end_line then
235421+
if start_line_start_char = end_line_end_char then
235422+
Format.fprintf ppf ":@{<dim>%i:%i@}" start_line
235423+
start_line_start_char
235424+
else
235425+
Format.fprintf ppf ":@{<dim>%i:%i-%i@}" start_line
235426+
start_line_start_char end_line_end_char
235434235427
else
235435-
Format.fprintf ppf ":@{<dim>%i:%i-%i@}" start_line
235436-
start_line_start_char end_line_end_char
235437-
else
235438-
Format.fprintf ppf ":@{<dim>%i:%i-%i:%i@}" start_line
235439-
start_line_start_char end_line end_line_end_char
235428+
Format.fprintf ppf ":@{<dim>%i:%i-%i:%i@}" start_line
235429+
start_line_start_char end_line end_line_end_char
235440235430
in
235441235431
Format.fprintf ppf "@{<filename>%a@}%a" print_filename file dim_loc
235442235432
normalizedRange
@@ -241933,7 +241923,6 @@ module GenType
241933241923
= struct
241934241924
#1 "GenType.ml"
241935241925
let processCmt cmt =
241936-
Log_.Color.forceColor := true;
241937241926
let config = Paths.readConfig ~namespace:(cmt |> Paths.findNameSpace) in
241938241927
if !Debug.basic then Log_.item "Add %s\n" cmt;
241939241928
cmt |> GenTypeMain.processCmtFile ~config

0 commit comments

Comments
 (0)