Skip to content

Commit

Permalink
bump glob to v10 (#658)
Browse files Browse the repository at this point in the history
closes #638

sort paths since they come back in reverse order now

---------

Co-authored-by: Misha Kaletsky <mmkal@users.noreply.github.com>
  • Loading branch information
mmkal and mmkal committed Mar 28, 2024
1 parent 53c9a54 commit cbfaadb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 59 deletions.
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": "^8.0.3",
"glob": "^10.3.10",
"pony-cause": "^2.1.4",
"type-fest": "^4.0.0"
},
Expand Down
61 changes: 9 additions & 52 deletions pnpm-lock.yaml

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

10 changes: 4 additions & 6 deletions src/umzug.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import emittery from 'emittery'
import * as fs from 'fs'
import glob from 'glob'
import {glob} from 'glob'
import * as path from 'path'
import * as errorCause from 'pony-cause'
import {promisify} from 'util'
import type {CommandLineParserOptions} from './cli'
import {UmzugCLI} from './cli'
import type {UmzugStorage} from './storage'
Expand All @@ -23,8 +22,6 @@ import type {
} from './types'
import {RerunBehavior} from './types'

const globAsync = promisify(glob)

type MigrationErrorParams = {
direction: 'up' | 'down'
} & MigrationParams<unknown>
Expand Down Expand Up @@ -489,12 +486,13 @@ export class Umzug<Ctx extends object = object> extends emittery<UmzugEvents<Ctx
}

const fileGlob = inputMigrations.glob
const [globString, globOptions]: Parameters<typeof glob.sync> = Array.isArray(fileGlob) ? fileGlob : [fileGlob]
const [globString, globOptions] = Array.isArray(fileGlob) ? fileGlob : [fileGlob]

const resolver: Resolver<Ctx> = inputMigrations.resolve ?? Umzug.defaultResolver

return async context => {
const paths = await globAsync(globString, {...globOptions, absolute: true})
const paths = await glob(globString, {...globOptions, withFileTypes: 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)
const name = path.basename(filepath)
Expand Down

0 comments on commit cbfaadb

Please sign in to comment.