simplify addSuffixToFilePath
This commit is contained in:
parent
4d10d72e91
commit
4286f7eda1
|
|
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue