Skip to content

Commit 2752835

Browse files
committed
docs(changeset): Add logs
1 parent a96c95e commit 2752835

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.changeset/ready-islands-greet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"git-json-resolver": patch
3+
---
4+
5+
Add logs

lib/src/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Config, InbuiltMergeStrategies } from "./types";
77
import { backupFile, listMatchingFiles } from "./utils";
88
import fs from "node:fs/promises";
99
import { reconstructConflict } from "./conflict-helper";
10+
import { globalLogger } from "./logger";
1011

1112
export * from "./types";
1213

@@ -17,6 +18,9 @@ export const resolveConflicts = async <T extends string = InbuiltMergeStrategies
1718
) => {
1819
const normalizedConfig: NormalizedConfig = await normalizeConfig<T>(config);
1920
const filesEntries = await listMatchingFiles(normalizedConfig);
21+
if (normalizedConfig.debug) {
22+
globalLogger.info("all", JSON.stringify({ normalizedConfig, filesEntries }, null, 2));
23+
}
2024
await Promise.all(
2125
filesEntries.map(async ({ filePath, content }) => {
2226
const { theirs, ours, format } = await parseConflictContent(content, { filename: filePath });
@@ -38,6 +42,10 @@ export const resolveConflicts = async <T extends string = InbuiltMergeStrategies
3842
backupFile(filePath),
3943
]);
4044

45+
if (normalizedConfig.debug) {
46+
globalLogger.debug(filePath, JSON.stringify({ merged, conflicts }, null, 2));
47+
}
48+
4149
if (conflicts.length === 0) {
4250
const serialized = await serialize(format, merged);
4351
await fs.writeFile(filePath, serialized, "utf8");
@@ -53,4 +61,5 @@ export const resolveConflicts = async <T extends string = InbuiltMergeStrategies
5361
}
5462
}),
5563
);
64+
globalLogger.flush();
5665
};

0 commit comments

Comments
 (0)