fix(deps): libxmljs2 is now an optional dependency and can be handled if missing
This commit is contained in:
466
package-lock.json
generated
466
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,7 @@
|
||||
"transform": {}
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"gifencoder": "^2.0.1"
|
||||
"gifencoder": "^2.0.1",
|
||||
"libxmljs2": "^0.30.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,12 +186,20 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
|
||||
//Verify svg
|
||||
if (verify) {
|
||||
console.debug(`metrics/compute/${login} > verify SVG`)
|
||||
const libxmljs = (await import("libxmljs2")).default
|
||||
let libxmljs = null
|
||||
try {
|
||||
libxmljs = (await import("libxmljs2")).default
|
||||
}
|
||||
catch (error) {
|
||||
console.debug(`metrics/compute/${login} > failed to import libxmljs2 (${error}), ignoring SVG verification`)
|
||||
}
|
||||
if (!libxmljs) {
|
||||
const parsed = libxmljs.parseXml(rendered)
|
||||
if (parsed.errors.length)
|
||||
throw new Error(`Malformed SVG : \n${parsed.errors.join("\n")}`)
|
||||
console.debug(`metrics/compute/${login} > verified SVG, no parsing errors found`)
|
||||
}
|
||||
}
|
||||
//Resizing
|
||||
const {resized, mime} = await imports.svg.resize(rendered, {paddings: q["config.padding"] || conf.settings.padding, convert: convert === "svg" ? null : convert, scripts: [...data.postscripts, extras.js || null].filter(x => x)})
|
||||
rendered = resized
|
||||
|
||||
Reference in New Issue
Block a user