Fix typing in scripts

This commit is contained in:
Pieter Vander Vennet 2023-01-17 01:53:50 +01:00
parent 6ca5c31e3a
commit 3c345f43a3
2 changed files with 8 additions and 7 deletions

View file

@ -442,29 +442,30 @@ class LayerOverviewUtils {
if (themeFile.icon.endsWith(".svg")) {
try {
ScriptUtils.ReadSvgSync(json.icon, (svg) => {
ScriptUtils.ReadSvgSync(themeFile.icon, (svg) => {
const width: string = svg.$.width
const height: string = svg.$.height
const err = themeFile.hideFromOverview ? console.warn : console.error
if (width !== height) {
const e =
`the icon for theme ${json.id} is not square. Please square the icon at ${json.icon}` +
`the icon for theme ${themeFile.id} is not square. Please square the icon at ${themeFile.icon}` +
` Width = ${width} height = ${height}`
;(json.hideFromOverview ? warnings : errors).push(e)
err(e)
}
const w = parseInt(width)
const h = parseInt(height)
if (w < 370 || h < 370) {
const e: string = [
`the icon for theme ${json.id} is too small. Please rescale the icon at ${json.icon}`,
`the icon for theme ${themeFile.id} is too small. Please rescale the icon at ${themeFile.icon}`,
`Even though an SVG is 'infinitely scaleable', the icon should be dimensioned bigger. One of the build steps of the theme does convert the image to a PNG (to serve as PWA-icon) and having a small dimension will cause blurry images.`,
` Width = ${width} height = ${height}; we recommend a size of at least 500px * 500px and to use a square aspect ratio.`,
].join("\n")
;(json.hideFromOverview ? warnings : errors).push(e)
err(e)
}
})
} catch (e) {
console.error("Could not read " + json.icon + " due to " + e)
console.error("Could not read " + themeFile.icon + " due to " + e)
}
}

View file

@ -76,7 +76,7 @@ async function readGeojsonLineByLine(inputFile: string): Promise<any[]> {
async function readFeaturesFromGeoJson(inputFile: string): Promise<any[]> {
try {
return JSON.parse(fs.readFileSync(inputFile, "UTF-8")).features
return JSON.parse(fs.readFileSync(inputFile, { encoding: "utf-8" })).features
} catch (e) {
// We retry, but with a line-by-line approach
return await readGeojsonLineByLine(inputFile)