Skip to content

Commit 3b1eb92

Browse files
committed
fix cli tests
1 parent c544bf9 commit 3b1eb92

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/src/cli.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe("cli helpers", () => {
8686
it("warns on unknown option", () => {
8787
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
8888
(cli as any).parseArgs(["node", "cli", "--unknown"]);
89-
expect(warn).toHaveBeenCalledWith("[git-json-resolver] Unknown option: --unknown");
89+
expect(warn).toHaveBeenCalledWith("Unknown option: --unknown");
9090
});
9191
});
9292

@@ -102,9 +102,7 @@ describe("cli helpers", () => {
102102
(cli as any).initConfig(tmpDir);
103103

104104
expect(writeFileSync).toHaveBeenCalled();
105-
expect(log).toHaveBeenCalledWith(
106-
`[git-json-resolver] Created starter config at ${configPath}`,
107-
);
105+
expect(log).toHaveBeenCalledWith(`Created starter config at ${configPath}`);
108106
});
109107

110108
it("exits if config already exists", () => {
@@ -115,9 +113,7 @@ describe("cli helpers", () => {
115113
const error = vi.spyOn(console, "error").mockImplementation(() => {});
116114

117115
expect(() => (cli as any).initConfig(tmpDir)).toThrow("exit");
118-
expect(error).toHaveBeenCalledWith(
119-
`[git-json-resolver] Config file already exists: ${configPath}`,
120-
);
116+
expect(error).toHaveBeenCalledWith(`Config file already exists: ${configPath}`);
121117
expect(exit).toHaveBeenCalledWith(1);
122118
});
123119
});

lib/src/logger.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const createLogger = (config: LoggerConfig = {}) => {
2020
try {
2121
if (!fs.existsSync(logDir)) fs.mkdirSync(logDir, { recursive: true });
2222
} catch (error) {
23+
/* v8 ignore next 2 -- logs only */
2324
console.warn(`Failed to create log directory: ${error}`);
2425
}
2526

@@ -64,9 +65,12 @@ export const createLogger = (config: LoggerConfig = {}) => {
6465
logDir,
6566
singleFile ? `combined-${timestamp}.log` : `${fileId}-${timestamp}.log`,
6667
);
67-
const lines = entries.map(e => `[${e.timestamp}] [${e.level.toUpperCase()}] ${e.message}`);
68+
const lines = entries.map(
69+
e => `[${e.timestamp}] [${e.level.toUpperCase()}] ${e.message}`,
70+
);
6871
fs.writeFileSync(filePath, lines.join("\n") + "\n", { flag: "a" });
6972
} catch (error) {
73+
/* v8 ignore next 2 -- logs only */
7074
console.warn(`Failed to write log file for ${fileId}: ${error}`);
7175
}
7276
}
@@ -75,6 +79,7 @@ export const createLogger = (config: LoggerConfig = {}) => {
7579
try {
7680
s.end();
7781
} catch (error) {
82+
/* v8 ignore next 2 -- logs only */
7883
console.warn(`Failed to close log stream: ${error}`);
7984
}
8085
}

0 commit comments

Comments
 (0)