Skip to content

Commit 1f9a6a7

Browse files
Merge pull request #51 from codecov/spalmurray/custom-colors
feat(coverage): Add support for custom colors
2 parents ef09a05 + 9e10f0f commit 1f9a6a7

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

package.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,37 @@
113113
"description": "Toggle Codecov line coverage decorations.",
114114
"order": 0
115115
},
116+
"codecov.coverage.colors.covered": {
117+
"type": "string",
118+
"default": "rgb(33,181,119)",
119+
"description": "The CSS color Codecov should use for covered lines (e.g., green, hsl(120deg 100% 50%), #00FF00).",
120+
"order": 1
121+
},
122+
"codecov.coverage.colors.partial": {
123+
"type": "string",
124+
"default": "rgb(244,176,27)",
125+
"description": "The CSS color Codecov should use for partial lines (e.g., green, hsl(120deg 100% 50%), #00FF00).",
126+
"order": 2
127+
},
128+
"codecov.coverage.colors.missed": {
129+
"type": "string",
130+
"default": "rgb(245,32,32)",
131+
"description": "The CSS color Codecov should use for missed lines (e.g., green, hsl(120deg 100% 50%), #00FF00).",
132+
"order": 3
133+
},
116134
"codecov.api.gitProvider": {
117135
"type": "string",
118136
"default": "github",
119137
"enum": ["github", "github_enterprise", "gitlab", "gitlab_enterprise", "bitbucket", "bitbucket_server"],
120138
"description": "Where are your repositories hosted?",
121-
"order": 1
139+
"order": 4
122140
},
123141
"codecov.api.url": {
124142
"type": "string",
125143
"default": "https://api.codecov.io",
126144
"format": "url",
127145
"description": "If you're self-hosting Codecov, update this to point to your self-hosted API.",
128-
"order": 2
146+
"order": 5
129147
}
130148
}
131149
}

src/coverage/coverage.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ type Coverage =
2222
}
2323
| undefined;
2424

25+
const config = workspace.getConfiguration("codecov");
26+
2527
const Colors = {
26-
covered: "rgb(33,181,119)",
27-
partial: "rgb(244,176,27)",
28-
missed: "rgb(245,32,32)",
28+
covered: config.get("coverage.colors.covered") || "rgb(33,181,119)",
29+
partial: config.get("coverage.colors.partial") || "rgb(244,176,27)",
30+
missed: config.get("coverage.colors.missed") || "rgb(245,32,32)",
2931
} as const;
3032

3133
const Icons = {
@@ -90,8 +92,6 @@ export function activateCoverage(context: ExtensionContext) {
9092
return;
9193
}
9294

93-
const config = workspace.getConfiguration("codecov");
94-
9595
const enabled = config.get("coverage.enabled");
9696
if (!enabled) return;
9797

0 commit comments

Comments
 (0)