call path.basename w/ extension name to avoid e.g. `.js.1.js`

This commit is contained in:
Michael Bradley, Jr 2018-10-03 14:54:53 -05:00 committed by Pascal Precht
parent 882271dc60
commit 09734d7879
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
1 changed files with 2 additions and 1 deletions

View File

@ -120,9 +120,10 @@ function copyPreserve(sourceFilePath, targetFilePath) {
let ext = 1; let ext = 1;
let preserved = targetFilePath; let preserved = targetFilePath;
while (fs.existsSync(preserved)) { while (fs.existsSync(preserved)) {
let extname = path.extname(targetFilePath);
preserved = utils.joinPath( preserved = utils.joinPath(
path.dirname(targetFilePath), path.dirname(targetFilePath),
`${path.basename(targetFilePath)}.${ext}${path.extname(targetFilePath)}` `${path.basename(targetFilePath, extname)}.${ext}${extname}`
); );
ext++; ext++;
} }