Skip to content

Commit

Permalink
feature: allow hash in color codes
Browse files Browse the repository at this point in the history
  • Loading branch information
davorpa committed Oct 24, 2022
1 parent 445ae22 commit 9b78520
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/labeler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,18 @@ export class Labeler {
}

private static async loadLabelsFromYAML(yamlFile: fs.PathLike): Promise<Label[]> {
return yaml.load(fs.readFileSync(yamlFile, {encoding: 'utf-8'})) as Promise<Label[]>;
const fileLabels = yaml.load(fs.readFileSync(yamlFile, {encoding: 'utf-8'})) as Promise<Label[]>;
//Feature #153: Allow hash in color codes
const labelColorMapper = label => {
let color = label.color;
// strip hash if starts with... (GitHub API labels are without it)
if (color.indexOf('#') === 0) {
color = color.substring(1);
}
label.color = color;
return label;
};
return fileLabels.then(labels => labels.map(labelColorMapper));
}

private async computeActionLabels(): Promise<Label[]> {
Expand Down

0 comments on commit 9b78520

Please sign in to comment.