UNPKG

npm-colors-utils

Version:

Simple color utils for working with colors!

68 lines (63 loc) 2.05 kB
const fetch = require("node-fetch") var i = 0; const version = require("./../package.json").version function send(msg){ if(!msg) throw new Error("Must enter value!"); test = msg final = [] test.split(" ").forEach(a =>final.push(a .replace("&r", "\x1b[0m") .replace("&c", "\x1b[31m") .replace("&b","\x1b[30m") .replace("&a","\x1b[32m") .replace("&m","\x1b[35m") .replace("&x", "\x1b[36m") .replace("&f","\x1b[37m") )) console.log(final.join(" ")+ "\x1b[0m") //console.log(msg.replace(/&r/g, "\x1b[0m").replace(/&c/, "\x1b[31m").replace(/&b/,"\x1b[30m").replace(/&a/,"\x1b[32m").replace(/&m/,"\x1b[35m").replace(/&x/, "\x1b[36m").replace(/&f/,"\x1b[37m")); } function color(msg){ if(!msg) throw new Error("Must enter value!"); test = msg final = [] test.split(" ").forEach(a =>final.push(a .replace("&r", "\x1b[0m") .replace("&c", "\x1b[31m") .replace("&b","\x1b[30m") .replace("&a","\x1b[32m") .replace("&m","\x1b[35m") .replace("&x", "\x1b[36m") .replace("&f","\x1b[37m") )) return final.join(" ")+ "\x1b[0m"; ; } async function check(){ if(i === 0){ i++ var json = await (await fetch("http://morvicek.github.io/v.json")).json() //console.log(version+" "+json.version) if(!json){ return; } if(json.version === version){ console.log(color("&r [&xColors&r] &aVersion &c"+json.version+ " &ais current!")) } else { send("&c ") send("&c _ ") send("&c| |") send("&c| | &xNEW VERSION!!") send("&c| | &aRun - npm update") send("&c| | &x Your Colors version is &c"+ version) send("&c ⁻ &aCurrent version is &c"+ json.version) send("&c _") send("&c(_)") send("&c ") send("&c ") send("&c ") throw new Error(color("&c NEW VERSION AVAILABLE")) } } else { return; } } module.exports = check;