simplify addSuffixToFilePath

This commit is contained in:
Yury Semikhatsky 2024-03-08 15:39:43 -08:00
parent 4d10d72e91
commit 4286f7eda1

View file

@ -195,12 +195,10 @@ export function trimLongString(s: string, length = 100) {
return s.substring(0, start) + middle + s.slice(-end); return s.substring(0, start) + middle + s.slice(-end);
} }
export function addSuffixToFilePath(filePath: string, suffix: string, customExtension?: string, sanitize = false): string { export function addSuffixToFilePath(filePath: string, suffix: string): string {
const dirname = path.dirname(filePath);
const ext = path.extname(filePath); const ext = path.extname(filePath);
const name = path.basename(filePath, ext); const base = filePath.substring(0, filePath.length - ext.length);
const base = path.join(dirname, name); return base + suffix + ext;
return (sanitize ? sanitizeForFilePath(base) : base) + suffix + (customExtension || ext);
} }
/** /**