Files
shields/lib/load-logos.js
Paul Melnikow 66d444aa40 Clean up our callback style and enforce no exclusive tests and remove an exclusive test (#1900)
We use arrow functions in most places; this enforces it.

Passing arrow functions to Mocha is discouraged: https://mochajs.org/#arrow-functions

This was a mix of autofixes and hand adjustments.
2018-08-12 20:45:43 -04:00

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