Move colorsets into json file (#77)
This commit is contained in:
4
source/plugins/languages/colorsets.json
Normal file
4
source/plugins/languages/colorsets.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"rainbow":["0:#ff0000", "1:#ffa500", "2:#ffff00", "3:#008000", "4:#0000ff", "5:#4b0082", "6:#ee82ee", "7:#162221"],
|
||||||
|
"complementary":["0:#ff0000", "1:#008000", "2:#ffa500", "3:#0000ff", "4:#ffff00", "5:#4b0082", "6:#162221", "7:#ee82ee"]
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//Setup
|
//Setup
|
||||||
export default async function ({login, data, q}, {enabled = false} = {}) {
|
export default async function ({login, data, imports, q}, {enabled = false} = {}) {
|
||||||
//Plugin execution
|
//Plugin execution
|
||||||
try {
|
try {
|
||||||
//Check if plugin is enabled and requirements are met
|
//Check if plugin is enabled and requirements are met
|
||||||
@@ -12,10 +12,9 @@
|
|||||||
//Skipped repositories
|
//Skipped repositories
|
||||||
skipped = decodeURIComponent(skipped).split(",").map(x => x.trim().toLocaleLowerCase()).filter(x => x)
|
skipped = decodeURIComponent(skipped).split(",").map(x => x.trim().toLocaleLowerCase()).filter(x => x)
|
||||||
//Custom colors
|
//Custom colors
|
||||||
if (`${colors}` === "rainbow")
|
const colorsets = JSON.parse(`${await imports.fs.readFile(`${imports.__module(import.meta.url)}/colorsets.json`)}`)
|
||||||
colors = ["0:#ff0000", "1:#ffa500", "2:#ffff00", "3:#008000", "4:#0000ff", "5:#4b0082", "6:#ee82ee", "7:#162221"]
|
if (`${colors}` in colorsets)
|
||||||
if (`${colors}` === "complementary")
|
colors = colorsets[`${colors}`]
|
||||||
colors = ["0:#ff0000", "1:#008000", "2:#ffa500", "3:#0000ff", "4:#ffff00", "5:#4b0082", "6:#162221", "7:#ee82ee"]
|
|
||||||
colors = Object.fromEntries(decodeURIComponent(colors).split(",").map(x => x.trim().toLocaleLowerCase()).filter(x => x).map(x => x.split(":").map(x => x.trim())))
|
colors = Object.fromEntries(decodeURIComponent(colors).split(",").map(x => x.trim().toLocaleLowerCase()).filter(x => x).map(x => x.split(":").map(x => x.trim())))
|
||||||
console.debug(`metrics/compute/${login}/plugins > languages > custom colors ${JSON.stringify(colors)}`)
|
console.debug(`metrics/compute/${login}/plugins > languages > custom colors ${JSON.stringify(colors)}`)
|
||||||
//Iterate through user's repositories and retrieve languages data
|
//Iterate through user's repositories and retrieve languages data
|
||||||
|
|||||||
Reference in New Issue
Block a user