Skip to content

Commit

Permalink
fix: migration files not sorted by timestamp when using glob
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Kroeger <[email protected]>
  • Loading branch information
benkroeger committed Nov 18, 2024
1 parent c50d7ca commit 0313eb6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,16 @@ export async function getMigrationFilePaths(
const globMatches = await glob(dir, {
ignore: ignorePattern,
nodir: true,
absolute: true,
withFileTypes: true,
});
return globMatches.sort(localeCompareStringsNumerically);

return globMatches
.sort(
(a, b) =>
compareFileNamesByTimestamp(a.name, b.name, logger) ||
localeCompareStringsNumerically(a.name, b.name)
)
.map((pathScurry) => pathScurry.fullpath());
}

if (Array.isArray(dir) || Array.isArray(ignorePattern)) {
Expand Down

0 comments on commit 0313eb6

Please sign in to comment.