fix(cli): remove the double period before file extension in new migration files

This commit is contained in:
Joakim Carlstein 2023-11-22 13:10:08 +01:00
parent 7d8ac9b185
commit 1940885134
2 changed files with 7 additions and 4 deletions

View file

@ -0,0 +1,5 @@
---
'@emigrate/cli': patch
---
Remove the double period before the file extension when generating new migration files

View file

@ -34,9 +34,7 @@ export default async function newCommand({ directory, template, plugins = [], ex
throw new UnexpectedError(`Failed to read template file: ${templatePath}`, { cause: error });
}
filename = `${getTimestampPrefix()}_${sanitizeMigrationName(name)}.${withLeadingPeriod(
extension ?? fileExtension,
)}`;
filename = `${getTimestampPrefix()}_${sanitizeMigrationName(name)}${withLeadingPeriod(extension ?? fileExtension)}`;
}
let hasGeneratedFile = Boolean(filename && content !== undefined);
@ -56,7 +54,7 @@ export default async function newCommand({ directory, template, plugins = [], ex
if (extension && !hasGeneratedFile) {
content = '';
filename = `${getTimestampPrefix()}_${sanitizeMigrationName(name)}.${withLeadingPeriod(extension)}`;
filename = `${getTimestampPrefix()}_${sanitizeMigrationName(name)}${withLeadingPeriod(extension)}`;
}
if (!filename || content === undefined) {