Created
December 5, 2019 09:34
-
-
Save pavermakov/ad27eb6a429c547970e4220de6edaa11 to your computer and use it in GitHub Desktop.
Generate icomoon icons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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