Throw error if no replacements were made
This commit is contained in:
parent
f2b4f2e069
commit
c0fb8a2c77
1 changed files with 3 additions and 0 deletions
|
@ -26,6 +26,9 @@ module.exports.buildColorizedSVG = function (svgLocation, primaryColor, secondar
|
||||||
const svgCode = fs.readFileSync(svgLocation, { encoding: "utf8"});
|
const svgCode = fs.readFileSync(svgLocation, { encoding: "utf8"});
|
||||||
let coloredSVGCode = svgCode.replaceAll("#ff00ff", primaryColor);
|
let coloredSVGCode = svgCode.replaceAll("#ff00ff", primaryColor);
|
||||||
coloredSVGCode = coloredSVGCode.replaceAll("#00ffff", secondaryColor);
|
coloredSVGCode = coloredSVGCode.replaceAll("#00ffff", secondaryColor);
|
||||||
|
if (svgCode === coloredSVGCode) {
|
||||||
|
throw new Error("svg-colorizer made no color replacements! The input svg should only contain colors #ff00ff (primary, case-sensitive) and #00ffff (secondary, case-sensitive).");
|
||||||
|
}
|
||||||
const fileName = svgLocation.match(/.+\/(.+\.svg)/)[1];
|
const fileName = svgLocation.match(/.+\/(.+\.svg)/)[1];
|
||||||
const outputPath = path.resolve(__dirname, "../../.tmp");
|
const outputPath = path.resolve(__dirname, "../../.tmp");
|
||||||
try {
|
try {
|
||||||
|
|
Reference in a new issue