Fix non-ascii characters, add check for them

This commit is contained in:
Pieter Vander Vennet 2022-07-26 11:38:10 +02:00
parent 2f6b43796b
commit 512a11740e
2 changed files with 47 additions and 76 deletions

View file

@ -17,13 +17,18 @@ function genImages(dryrun = false) {
throw "Non-svg file detected in the svg files: " + path;
}
let svg = fs.readFileSync("./assets/svg/" + path, "utf-8")
let svg : string = fs.readFileSync("./assets/svg/" + path, "utf-8")
.replace(/<\?xml.*?>/, "")
.replace(/fill: ?none;/g, "fill: none !important;") // This is such a brittle hack...
.replace(/\n/g, " ")
.replace(/\r/g, "")
.replace(/\\/g, "\\")
.replace(/"/g, "\\\"")
let hasNonAsciiChars = Array.from(svg).some(char => char.charCodeAt(0) > 127);
if(hasNonAsciiChars){
throw "The svg '"+path+"' has non-ascii characters";
}
const name = path.substr(0, path.length - 4)
.replace(/[ -]/g, "_");