chore: Fixes accents replacement regexp.

This commit is contained in:
octod 2017-11-01 14:33:47 +01:00
parent c42f1962c9
commit ea44eeb52b

View file

@ -42,13 +42,17 @@ function replaceNameWithAccent(name: string, accentName: string): string {
* @returns {string} * @returns {string}
*/ */
export function replaceSVGColour(filecontent: string, colour: string): string { export function replaceSVGColour(filecontent: string, colour: string): string {
return filecontent.replace(new RegExp('.st0\{fill:\s{0,}#([a-zA-Z0-9]{6})\}|path fill="#([a-zA-Z0-9]{6})"'), ($0, $1, $2) => { return filecontent.replace(new RegExp('.st0\{fill:\s{0,}#([a-zA-Z0-9]{6})|path fill="#([a-zA-Z0-9]{6})"'), ($0, $1, $2) => {
colour = colour.replace('#', ''); colour = colour.replace('#', '');
if (!$2) { if (!$2) {
console.log(`Replacing colour ${ $1 } with ${ colour }`)
return $0.replace($1, colour); return $0.replace($1, colour);
} else { } else {
console.log(`Replacing colour ${ $2 } with ${ colour }`)
return $0.replace($2, colour); return $0.replace($2, colour);
} }
}); });