fix(kit): use path.basename/dirname in embeddedMigrations to fix Windows path separators#5518
Open
sleitor wants to merge 1 commit intodrizzle-team:betafrom
Open
fix(kit): use path.basename/dirname in embeddedMigrations to fix Windows path separators#5518sleitor wants to merge 1 commit intodrizzle-team:betafrom
sleitor wants to merge 1 commit intodrizzle-team:betafrom
Conversation
…ows path separators
On Windows, path.join() produces backslash-separated paths. The previous
implementation used entry.split('/') which always splits on forward slash,
causing the parent directory name (migration folder name) to be undefined
on Windows, resulting in 'undefined' appearing in the generated migrations.js.
Fixes drizzle-team#5514
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #5514.
On Windows, snapshot file paths use backslash separators (e.g.
C:\project\drizzle\20260320055809_initial\snapshot.json). The previous implementation usedentry.split('/')[...length - 2]to extract the migration folder name. Since Windows paths contain only backslashes,split('/')returns a single-element array and[length - 2]isundefined, causingmigrations.jsto import from'./undefined/migration.sql'.Fix
Replace the slash-split approach with
path.basename(path.dirname(entry)), which correctly extracts the parent directory name on all platforms (POSIX and Windows).pathis already imported in this file. Thepathmodule automatically handles both forward-slash and backslash separators on Windows viapath.dirname/path.basename.