Skip to content

Instantly share code, notes, and snippets.

@pavermakov
Created December 5, 2019 09:34
Show Gist options
  • Save pavermakov/ad27eb6a429c547970e4220de6edaa11 to your computer and use it in GitHub Desktop.
Save pavermakov/ad27eb6a429c547970e4220de6edaa11 to your computer and use it in GitHub Desktop.
Generate icomoon icons
/* eslint-disable no-console */
const fs = require("fs");
const path = require("path");
const pipeline = require("icomoon-cli");
const ICONS_FOLDER = path.join(__dirname, "../icons");
const SELECTION_PATH = path.join(__dirname, "../../configs/humanforce-font-selection.json");
function getIcons() {
return fs.readdirSync(ICONS_FOLDER);
}
function getNames(icons) {
return icons.map((icon) => {
return icon.split(".")[0];
});
}
function generateJSON(icons) {
pipeline({
icons,
names: getNames(icons),
selectionPath: SELECTION_PATH,
outputDir: "output",
forceOverride: true,
// visible: true,
whenFinished(result) {
// you can get the absolute path of output directory via result.outputDir
}
});
}
try {
const icons = getIcons();
generateJSON(icons);
} catch (error) {
console.log("\x1b[31mFailed to get icons");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment