Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds glob support for dir and ignorePattern #1274

Merged
merged 10 commits into from
Sep 23, 2024
Prev Previous commit
updates jsdoc comments
Signed-off-by: Benjamin Kroeger <[email protected]>
  • Loading branch information
benkroeger committed Sep 23, 2024
commit 77720e0d5a141bd2efa858d7a95f5e720a742908
10 changes: 5 additions & 5 deletions src/migration.ts
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ interface LoadMigrationFilesOptions {
}

/**
* reads files from `dir`, sorts them and returns an array of their absolute paths.
* Reads files from `dir`, sorts them and returns an array of their absolute paths.
* When not using globs, files are sorted by their numeric prefix values first. 17 digit numbers are interpreted as utc date and converted to the number representation of that date.
* Glob matches are sorted via String.localeCompare with ignored punctuation.
*
@@ -102,8 +102,8 @@ interface LoadMigrationFilesOptions {
* an array of glob patterns and set `options.useGlob = true`
*
* Note: enabling glob will read both, `dir` _and_ `options.ignorePattern` as glob patterns
* @param {LoadMigrationFilesOptions} options
* @returns {Promise<Array<String>>} Array of absolute paths
* @param options
* @returns Array of absolute paths
*/
export async function getMigrationFilePaths(
/**
@@ -123,7 +123,7 @@ export async function getMigrationFilePaths(
* it is not the first item in the pattern, or none if it is the
* first item in the pattern, following the same behavior as Bash.
*
* only want files, no dirs.
* Only want files, no dirs.
*/
const globMatches = await glob(dir, { ignore: ignorePattern, nodir: true });
return globMatches.sort(localeCompareStringsNumerically);
@@ -177,7 +177,7 @@ async function getLastSuffix(
* 17 digit numbers are interpreted as utc date and converted to the number representation of that date.
* @param filename filename to extract the prefix from
* @param logger Redirect messages to this logger object, rather than `console`.
* @returns {number} numeric value of the filename prefix (everything before SEPARATOR).
* @returns numeric value of the filename prefix (everything before `SEPARATOR`).
*/
export function getNumericPrefix(
filename: string,