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

Postgrator version 8 - possible glob character break on Windows #172

Open
daniele-paltrinieri-79 opened this issue Feb 13, 2025 · 0 comments

Comments

@daniele-paltrinieri-79
Copy link

Describe the bug
After upgrading to version 8 of the library, a migration pattern created as migrationPattern = path.join(__dirname, 'migrations', '*') does not return any migrations files. Calling postgrator.getMigrations() return an empty array

Expected behavior
The migrations files will be loaded as it happens in versione 7.3

Additional context
I have done some analysis and I think the problem could happen because of these note on the glob project

Note Glob patterns should always use / as a path separator, even on Windows systems, as \ is used to escape glob characters. If you wish to use \ as a path separator instead of using it as an escape character on Windows platforms, you may set windowsPathsNoEscape:true in the options. In this mode, special glob characters cannot be escaped, making it impossible to match a literal * ? and so on in filenames.

I was able to make it works in 2 possible ways:

  • add a character replace to the migration pattern, ex: migrationPattern = path.join(__dirname, 'migrations', '*').replace(/\\/g,'/')
  • changing the getMigrations() function of postgrator, setting in the glob call the parameter allowWindowsEscape: false, const migrationFiles = await glob(migrationPattern, {allowWindowsEscape: false});

Both the solution solve the problem, and a filled array is returned when postgrator.getMigrations() is called.

System information

  • Node v20.18.3
  • Postgrator 8.0.0
  • Glob 11.0.0
  • Microsoft Windows 11 Pro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant