Skip to content

Commit

Permalink
fix: restore node12 support (glob -> fast-glob) (#660)
Browse files Browse the repository at this point in the history
fixes #659

Note that there are some edge-case differences between glob and
fast-glob, but it's very unlikely that users of umzug will hit them.

See glob docs for an in-depth comparison:
https://github.com/isaacs/node-glob?tab=readme-ov-file#comparison-to-other-javascript-glob-implementations

If there's anyone that needs the old `glob` behaviour, they can use glob
themselves and pass an array of migrations to umzug. (see
https://github.com/sequelize/umzug#direct-migrations-list)
  • Loading branch information
mmkal committed Mar 28, 2024
1 parent e4f7865 commit b2a747c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
node migrate create --name new-migration.js
node migrate up
- name: run vanilla esm example
if: matrix.node != 12
working-directory: examples/0.5-vanilla-esm
run: |
npm init -y
Expand Down
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 [glob](https://npmjs.com/package/glob), will be lexicographically sorted based on their paths
- file matches, found using [fast-glob](https://npmjs.com/package/fast-glob), 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/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/fast-glob 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,7 +17,7 @@
"dependencies": {
"@rushstack/ts-command-line": "^4.12.2",
"emittery": "^0.13.0",
"glob": "^10.3.10",
"fast-glob": "^3.3.2",
"pony-cause": "^2.1.4",
"type-fest": "^4.0.0"
},
Expand Down
Loading

0 comments on commit b2a747c

Please sign in to comment.