From 8d117d94b751135cecd262d6419c00aecd2690f8 Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Sat, 23 Aug 2025 14:52:47 +0900 Subject: [PATCH] refactor(cli): Clean up binary files detection output format Remove redundant explanatory message from binary file listing to simplify output. The main header already explains the detection method, making individual file annotations unnecessary. Changes: - Remove "Detected as binary despite text extension" message from each file - Improve type safety by using FileSkipReason type instead of string - Update corresponding test expectations - Clean up unused import in fileCollectWorker The simplified output is cleaner while maintaining clarity about why files were excluded. --- src/cli/cliReport.ts | 3 +-- src/core/file/workers/fileCollectWorker.ts | 6 +++--- tests/cli/cliReport.binaryFiles.test.ts | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cli/cliReport.ts b/src/cli/cliReport.ts index 743a63e1..107589c9 100644 --- a/src/cli/cliReport.ts +++ b/src/cli/cliReport.ts @@ -169,7 +169,7 @@ export const reportSkippedFiles = (rootDir: string, skippedFiles: SkippedFileInf } logger.log(pc.white('📄 Binary Files Detected:')); - logger.log(pc.dim('──────────────────────────')); + logger.log(pc.dim('─────────────────────────')); if (binaryContentFiles.length === 1) { logger.log(pc.yellow('1 file detected as binary by content inspection:')); @@ -180,7 +180,6 @@ export const reportSkippedFiles = (rootDir: string, skippedFiles: SkippedFileInf binaryContentFiles.forEach((file, index) => { const relativeFilePath = path.relative(rootDir, file.path); logger.log(`${pc.white(`${index + 1}.`)} ${pc.white(relativeFilePath)}`); - logger.log(pc.dim(' - Detected as binary despite text extension')); }); logger.log(pc.yellow('\nThese files have been excluded from the output.')); diff --git a/src/core/file/workers/fileCollectWorker.ts b/src/core/file/workers/fileCollectWorker.ts index cf0205ad..564dc381 100644 --- a/src/core/file/workers/fileCollectWorker.ts +++ b/src/core/file/workers/fileCollectWorker.ts @@ -1,6 +1,6 @@ import path from 'node:path'; -import { logger, setLogLevelByWorkerData } from '../../../shared/logger.js'; -import { readRawFile } from '../fileRead.js'; +import { setLogLevelByWorkerData } from '../../../shared/logger.js'; +import { FileSkipReason, readRawFile } from '../fileRead.js'; import type { RawFile } from '../fileTypes.js'; // Initialize logger configuration from workerData at module load time @@ -15,7 +15,7 @@ export interface FileCollectTask { export interface SkippedFileInfo { path: string; - reason: string; + reason: FileSkipReason; } export interface FileCollectResult { diff --git a/tests/cli/cliReport.binaryFiles.test.ts b/tests/cli/cliReport.binaryFiles.test.ts index 51f7e283..68a52444 100644 --- a/tests/cli/cliReport.binaryFiles.test.ts +++ b/tests/cli/cliReport.binaryFiles.test.ts @@ -30,7 +30,6 @@ describe('reportSkippedFiles', () => { expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('📄 Binary Files Detected:')); expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('1 file detected as binary')); expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('dir/malformed.txt')); - expect(logger.log).toHaveBeenCalledWith(expect.stringContaining('Detected as binary despite text extension')); }); test('should report multiple binary-content files', () => {