Created
December 17, 2019 09:49
-
-
Save alexstrat/d5ce0a2f23e4f549ca65f3bc47483b0f to your computer and use it in GitHub Desktop.
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
import { readFileSync, writeFileSync } from 'fs'; | |
import { load } from 'cheerio'; | |
import { html as beautify } from 'js-beautify'; | |
const content = readFileSync('./static/Icons.svg', 'utf8'); | |
const $ = load(content); | |
$('svg').find('symbol').each((i, symbol) => { | |
const id = $(symbol).attr('id')!.split('--')[1]; | |
symbol.tagName = 'svg'; | |
$(symbol).removeAttr('id'); | |
writeFileSync(`./resources/icons/${id}.svg`, beautify($.html(symbol), { | |
indent_size: 2, | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment