fix(plugin-tools): remove double and trailing underscores from filenames and lower case the result
This commit is contained in:
parent
0081f77e86
commit
16340940b7
2 changed files with 11 additions and 1 deletions
5
.changeset/weak-avocados-lay.md
Normal file
5
.changeset/weak-avocados-lay.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@emigrate/plugin-tools': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Remove double and trailing underscores in sanitized filenames and lower case the result for consistent filenames
|
||||||
|
|
@ -53,4 +53,9 @@ export const getTimestampPrefix = () => new Date().toISOString().replaceAll(/[-:
|
||||||
* @param name A migration name to sanitize
|
* @param name A migration name to sanitize
|
||||||
* @returns A sanitized migration name that can be used as a filename
|
* @returns A sanitized migration name that can be used as a filename
|
||||||
*/
|
*/
|
||||||
export const sanitizeMigrationName = (name: string) => name.replaceAll(/[\W/\\:|*?'"<>]/g, '_').trim();
|
export const sanitizeMigrationName = (name: string) =>
|
||||||
|
name
|
||||||
|
.replaceAll(/[\W/\\:|*?'"<>]+/g, '_')
|
||||||
|
.trim()
|
||||||
|
.replace(/_$/, '')
|
||||||
|
.toLocaleLowerCase();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue