Skip to content

Commit 15d9f82

Browse files
fix: normalize paths for filePushOrder matching
Fixes an issue where `filePushOrder` fails to properly match and sort files on Windows or when paths have mixed directory separators (e.g. `\` vs `/`). By calling `path.normalize()` on both the files' `localPath` and the paths configured in `filePushOrder`, we ensure a consistent format is used for matching and ordering. Co-authored-by: sqrrrl <346343+sqrrrl@users.noreply.github.com>
1 parent 8bccc4e commit 15d9f82

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/core/files.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,10 @@ export class Files {
445445
}
446446

447447
const filePushOrder = this.options.files.filePushOrder ?? [];
448+
const normalizedFilePushOrder = filePushOrder.map(p => path.normalize(p));
448449
files.sort((a, b) => {
449-
const indexA = filePushOrder.indexOf(a.localPath);
450-
const indexB = filePushOrder.indexOf(b.localPath);
450+
const indexA = normalizedFilePushOrder.indexOf(path.normalize(a.localPath));
451+
const indexB = normalizedFilePushOrder.indexOf(path.normalize(b.localPath));
451452

452453
// If neither file is in the push order, sort them alphabetically.
453454
if (indexA === -1 && indexB === -1) {
@@ -510,10 +511,10 @@ export class Files {
510511
*/
511512
checkMissingFilesFromPushOrder(pushedFiles: ProjectFile[]) {
512513
const missingFiles = [];
513-
for (const path of this.options.files.filePushOrder ?? []) {
514-
const wasPushed = pushedFiles.find(f => f.localPath === path);
514+
for (const p of this.options.files.filePushOrder ?? []) {
515+
const wasPushed = pushedFiles.find(f => path.normalize(f.localPath) === path.normalize(p));
515516
if (!wasPushed) {
516-
missingFiles.push(path);
517+
missingFiles.push(p);
517518
}
518519
}
519520
}

0 commit comments

Comments
 (0)