Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd5d8912

Browse files
authored
ci: improve theme preview action (anuraghazra#2088)
This commit makes sure that 4,5,6,8 digit hex colors are also accepted.It further also includes the border_color attribute in the tests.
1 parent6b7e91a commitd5d8912

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

‎scripts/preview-theme.js

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Hjson from "hjson";
1212
importsnakeCasefrom"lodash.snakecase";
1313
importparsefrom"parse-diff";
1414
import{inspect}from"util";
15+
import{isValidHexColor}from"../src/common/utils.js";
1516
import{themes}from"../themes/index.js";
1617

1718
// Script variables
@@ -33,11 +34,11 @@ const THEME_CONTRIB_GUIDELINESS = `
3334
3435
\r> Also, note that if this theme is exclusively for your personal use, then instead of adding it to our theme collection, you can use card [customization options](https://github.com/anuraghazra/github-readme-stats#customization).
3536
`;
36-
constAVAILABLE_COLOR_PROPS=[
37-
"bg_color",
37+
constREQUIRED_COLOR_PROPS=[
38+
"title_color",
3839
"icon_color",
3940
"text_color",
40-
"title_color",
41+
"bg_color",
4142
];
4243
constINVALID_REVIEW_COMMENT=(commentUrl)=>
4344
`Some themes are invalid. See the [Automated Theme Preview](${commentUrl}) comment above for more information.`;
@@ -320,20 +321,6 @@ const parseJSON = (json) => {
320321
}
321322
};
322323

323-
/**
324-
* Check if string is a valid hex color.
325-
*
326-
*@param {string} str String to check.
327-
*@returns {boolean} Whether the string is a valid hex color.
328-
*/
329-
constisHexColor=(str,prefix=false)=>{
330-
if(prefix){
331-
return/^#[a-f0-9]{6}$/i.exec(str);
332-
}else{
333-
return/^[a-f0-9]{6}$/i.exec(str);
334-
}
335-
};
336-
337324
/**
338325
* Check whether the theme name is still available.
339326
*@param {string} name Theme name.
@@ -431,7 +418,7 @@ const run = async () => {
431418
warning.push("Theme colors are missing");
432419
invalidColors=true;
433420
}else{
434-
constmissingKeys=AVAILABLE_COLOR_PROPS.filter(
421+
constmissingKeys=REQUIRED_COLOR_PROPS.filter(
435422
(x)=>!Object.keys(colors).includes(x),
436423
);
437424
if(missingKeys.length>0){
@@ -446,7 +433,7 @@ const run = async () => {
446433
`Theme color property \`${colorKey}\` should not start with '#'`,
447434
);
448435
invalidColors=true;
449-
}elseif(!isHexColor(colorValue)){
436+
}elseif(!isValidHexColor(colorValue)){
450437
errors.push(
451438
`Theme color property \`${colorKey}\` is not a valid hex color: <code>#${colorValue}</code>`,
452439
);
@@ -476,6 +463,7 @@ const run = async () => {
476463
consticonColor=colors.icon_color;
477464
consttextColor=colors.text_color;
478465
constbgColor=colors.bg_color;
466+
constborderColor=colors.border_color;
479467
consturl=getGRSLink(colors);
480468
constcolorPairs={
481469
title_color:[titleColor,bgColor],
@@ -503,7 +491,9 @@ const run = async () => {
503491
504492
\r${warnings.map((warning)=>`- :warning:${warning}.\n`).join("")}
505493
506-
\ntitle_color: <code>#${titleColor}</code> | icon_color: <code>#${iconColor}</code> | text_color: <code>#${textColor}</code> | bg_color: <code>#${bgColor}</code>
494+
\ntitle_color: <code>#${titleColor}</code> | icon_color: <code>#${iconColor}</code> | text_color: <code>#${textColor}</code> | bg_color: <code>#${bgColor}</code>${
495+
borderColor ?` | border_color: <code>#${borderColor}</code>` :""
496+
}
507497
508498
\r[Preview Link](${url})
509499

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp