Add node-chartist support

This commit is contained in:
lowlighter
2021-03-21 13:07:41 +01:00
parent 24b822b694
commit 66ee6cb1be
3 changed files with 983 additions and 205 deletions

1179
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -37,6 +37,7 @@
"jimp": "^0.16.1",
"js-yaml": "^4.0.0",
"memory-cache": "^0.2.0",
"node-chartist": "^1.0.5",
"open-graph-scraper": "^4.7.1",
"prismjs": "^1.23.0",
"puppeteer": "^8.0.0",

View File

@@ -12,6 +12,7 @@
import jimp from "jimp"
import opengraph from "open-graph-scraper"
import rss from "rss-parser"
import nodechartist from "node-chartist"
//Exports
export {fs, os, paths, url, util, processes, axios, puppeteer, git, opengraph, rss}
@@ -97,6 +98,13 @@
.replace(/&/g, u["&"] ? "&" : "&")
}
/** Chartist */
export async function chartist() {
const css = `<style>${await fs.readFile(paths.join(__module(import.meta.url), "../../../node_modules", "node-chartist/dist/main.css")).catch(_ => "")}</style>`
return (await nodechartist(...arguments))
.replace(/class="ct-chart-line">/, `class="ct-chart-line">${css}`)
}
/**Run command */
export async function run(command, options, {prefixed = true} = {}) {
const prefix = {win32:"wsl"}[process.platform] ?? ""