Skip to content

Commit cb112b3

Browse files
committed
fix: improve debug logging and cross-platform path handling
- Add pretty-printing to debug JSON output for better readability - Fix Windows path separator normalization in file matching utilities - Ensure consistent cross-platform behavior for path handling
1 parent 5b64627 commit cb112b3

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"git-json-resolver": patch
3+
---
4+
5+
Improve debug logging and cross-platform path handling
6+
7+
- Enhanced debug logging with pretty-printed JSON output for better readability
8+
- Fixed Windows path separator handling in file matching utilities for consistent cross-platform behavior

lib/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const resolveConflicts = async <T extends string = InbuiltMergeStrategies
1919
filename: filePath,
2020
parsers: normalizedConfig.parsers,
2121
});
22-
globalLogger.debug(filePath, JSON.stringify({ ours, theirs, base, format }));
22+
globalLogger.debug(filePath, JSON.stringify({ ours, theirs, base, format }, null, 2));
2323
await processMerge({
2424
ours,
2525
theirs,

lib/src/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const listMatchingFiles = async ({
8787

8888
for (const entry of entries) {
8989
const fullPath = path.join(dir, entry.name);
90-
const relativePath = path.relative(root, fullPath);
90+
const relativePath = path.relative(root, fullPath).replace(/\\+/g, "/");
9191

9292
if (entry.isDirectory()) {
9393
/* v8 ignore next */
@@ -153,10 +153,9 @@ export const createSkipDirectoryMatcher = (
153153
}
154154

155155
return (dirPath: string) => {
156-
const posixPath = dirPath.replace(/\\/g, "/");
157156
return (
158-
matcher.isMatch(posixPath, [...dropDirs]) ||
159-
(keepDirs.size > 0 && !matcher.isMatch(posixPath, [...keepDirs]))
157+
matcher.isMatch(dirPath, [...dropDirs]) ||
158+
(keepDirs.size > 0 && !matcher.isMatch(dirPath, [...keepDirs]))
160159
);
161160
};
162161
};

0 commit comments

Comments
 (0)