46 lines
861 B
JavaScript
Raw Permalink Normal View History

2020-02-25 19:37:10 -08:00
const fs = require('fs-extra');
const actions = require('./actions');
const { resolve } = require('./resolve');
function any (input) {
for (const i of input) if (i) return i;
return false;
}
const MATCHES = [
'favicon.png',
'favicon.gif',
'favicon.jpeg',
'favicon.jpg',
];
module.exports = exports = async function favicon () {
const input = any(await Promise.all(
MATCHES.map((f) =>
fs.exists(resolve(f)).then((y) => y && f)
)
2020-02-25 19:37:10 -08:00
));
if (!input) return [];
// input = resolve(input);
const tasks = [ 32, 57, 64, 76, 96, 114, 120, 128, 144, 152, 180, 192, 196, 228 ].map((width) => ({
input,
output: `favicon${width}.png`,
format: 'png',
width,
action: actions.image,
}));
tasks.push({
input,
output: 'favicon.ico',
format: 'ico',
action: actions.image,
});
return tasks;
};