Skip to content

chore: switch to tinyglobby #705

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ const umzug = new Umzug({

Note on migration file sorting:

- file matches, found using [fast-glob](https://npmjs.com/package/fast-glob), will be lexicographically sorted based on their paths
- file matches, found using [tinyglobby](https://npmjs.com/package/tinyglobby), will be lexicographically sorted based on their paths
- so if your migrations are `one/m1.js`, `two/m2.js`, `three/m3.js`, the resultant order will be `one/m1.js`, `three/m3.js`, `two/m2.js`
- similarly, if your migrations are called `m1.js`, `m2.js`, ... `m10.js`, `m11.js`, the resultant ordering will be `m1.js`, `m10.js`, `m11.js`, ... `m2.js`
- The easiest way to deal with this is to ensure your migrations appear in a single folder, and their paths match lexicographically with the order they should run in
Expand All @@ -414,7 +414,7 @@ The Umzug class should be imported as a named import, i.e. `import { Umzug } fro

The `MigrationMeta` type, which is returned by `umzug.executed()` and `umzug.pending()`, no longer has a `file` property - it has a `name` and *optional* `path` - since migrations are not necessarily bound to files on the file system.

The `migrations.glob` parameter replaces `path`, `pattern` and `traverseDirectories`. It can be used, in combination with `cwd` and `ignore` to do much more flexible file lookups. See https://npmjs.com/package/fast-glob for more information on the syntax.
The `migrations.glob` parameter replaces `path`, `pattern` and `traverseDirectories`. It can be used, in combination with `cwd` and `ignore` to do much more flexible file lookups. See https://npmjs.com/package/tinyglobby for more information on the syntax.

The `migrations.resolve` parameter replaces `customResolver`. Explicit support for `wrap` and `nameFormatter` has been removed - these can be easily implemented in a `resolve` function.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"dependencies": {
"@rushstack/ts-command-line": "^4.12.2",
"emittery": "^0.13.0",
"fast-glob": "^3.3.2",
"pony-cause": "^2.1.4",
"tinyglobby": "^0.2.13",
"type-fest": "^4.0.0"
},
"devDependencies": {
Expand Down
48 changes: 45 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/umzug.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import emittery from 'emittery'
import {glob} from 'fast-glob'
import {glob} from 'tinyglobby'
import * as fs from 'fs'
import * as path from 'path'
import * as errorCause from 'pony-cause'
Expand Down Expand Up @@ -494,7 +494,7 @@ export class Umzug<Ctx extends object = object> extends emittery<UmzugEvents<Ctx
const resolver: Resolver<Ctx> = inputMigrations.resolve ?? Umzug.defaultResolver

return async context => {
const paths = await glob(globString, {...globOptions, ignore, absolute: true})
const paths = await glob(globString, {...globOptions, ignore, expandDirectories: false, absolute: true})
paths.sort() // glob returns results in reverse alphabetical order these days, but it has never guaranteed not to do that https://github.com/isaacs/node-glob/issues/570
return paths.map(unresolvedPath => {
const filepath = path.resolve(unresolvedPath)
Expand Down