This is consistent with what we're pretty much already doing, and saves us from making the request during code review. These were all autofixed and most of them seem easier to read. Some in the legacy services should be rewritten in more legible forms during refactor (ie using intermediate variables, or using request’s qs option). There are some in helper functions and elsewhere that should get rewritten separately. I don't want to change them in this PR because the changes will get lost in this diff, though we could identify them here and fix them before or just after.
31 lines
711 B
JavaScript
31 lines
711 B
JavaScript
'use strict'
|
|
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
const { svg2base64 } = require('./logo-helper')
|
|
|
|
function loadLogos() {
|
|
// Cache svg logos from disk in base64 string
|
|
const logos = {}
|
|
const logoDir = path.join(__dirname, '..', 'logo')
|
|
const logoFiles = fs.readdirSync(logoDir)
|
|
logoFiles.forEach(filename => {
|
|
if (filename[0] === '.') {
|
|
return
|
|
}
|
|
// filename is eg, github.svg
|
|
const svg = fs.readFileSync(`${logoDir}/${filename}`).toString()
|
|
const base64 = svg2base64(svg)
|
|
|
|
// eg, github
|
|
const name = filename.slice(0, -'.svg'.length).toLowerCase()
|
|
logos[name] = {
|
|
svg,
|
|
base64,
|
|
}
|
|
})
|
|
return logos
|
|
}
|
|
|
|
module.exports = loadLogos
|