Skip to content

Commit 917e03c

Browse files
committed
fix: normalize glob patterns for Windows compatibility in CLI index command
- Fix mixed path separators in glob patterns that could cause CLI failures on Windows - Ensure consistent forward slash usage in glob patterns across all platforms - Improve path handling to use consistent absolute paths in file filtering - This should resolve the Cross-Platform Tests workflow failures on Windows
1 parent 13a76f3 commit 917e03c

File tree

4 files changed

+925
-898
lines changed

4 files changed

+925
-898
lines changed

src/commands/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,9 @@ async function discoverMarkdownFiles(
272272
if (options.maxDepth !== undefined) {
273273
// Create depth-limited pattern
274274
const depthPattern = Array.from({ length: options.maxDepth }, () => '*').join('/');
275-
globPattern = join(targetDir, depthPattern, '*.md');
275+
globPattern = join(targetDir, depthPattern, '*.md').replace(/\\/g, '/');
276276
} else {
277-
globPattern = join(targetDir, '**/*.md');
277+
globPattern = join(targetDir, '**/*.md').replace(/\\/g, '/');
278278
}
279279

280280
const globOptions: Parameters<typeof glob>[1] = {
@@ -290,9 +290,12 @@ async function discoverMarkdownFiles(
290290

291291
// Filter files to respect boundary constraints and convert Path objects to strings
292292
const boundaryFilePaths = filePaths
293-
.map((filePath) => (typeof filePath === 'string' ? filePath : filePath.toString()))
293+
.map((filePath) => {
294+
const pathStr = typeof filePath === 'string' ? filePath : filePath.toString();
295+
return resolve(pathStr); // Ensure consistent absolute paths
296+
})
294297
.filter((filePath) => {
295-
const resolvedPath = resolve(filePath);
298+
const resolvedPath = filePath;
296299

297300
// Ensure file is within the boundary directory
298301
if (options.boundary) {

0 commit comments

Comments
 (0)