Skip to content

Commit

Permalink
Handle overwriting conflicts with icon generator
Browse files Browse the repository at this point in the history
  • Loading branch information
PKief committed Feb 23, 2020
1 parent 33a238a commit 7cd213b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/icons/generator/jsonGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ const renameIconFiles = (iconJsonPath: string, options: IconJsonOptions) => {

// append file config to file name
const newFilePath = path.join(iconJsonPath, '..', 'icons', f.replace(/(^[^\.~]+)(.*)\.svg/, `$1${fileConfig}.svg`));
fs.renameSync(filePath, newFilePath);

// if generated files are already in place, do not overwrite them
if (filePath !== newFilePath && fs.existsSync(newFilePath)) {
fs.unlinkSync(filePath);
} else {
fs.renameSync(filePath, newFilePath);
}
});
};

0 comments on commit 7cd213b

Please sign in to comment.