UNPKG

symref

Version:

Static code checker for AI code agents (Windsurf, Cline, etc.)

40 lines 1.7 kB
import * as path from 'path'; import * as fs from 'fs'; import { SymbolReferenceAnalyzer } from '../../analyzer'; import { OutputFormatter } from '../formatters/OutputFormatter'; /** * 未使用シンボル検出のコマンドクラス */ export class DeadCommand { /** * コマンドを実行する * @param file ファイルパス * @param options オプション */ static async execute(file, options) { try { const absolutePath = path.resolve(options.dir, file); if (!fs.existsSync(absolutePath)) { OutputFormatter.displayError(`ファイルが見つかりません: ${file}`, '\n以下を確認してください:\n' + '1. ファイルパスが正しいこと\n' + '2. 指定したディレクトリにファイルが存在すること\n' + '3. ファイルの読み取り権限があること\n'); process.exit(1); } const analyzerOptions = { basePath: options.dir, tsConfigPath: options.project, includePatterns: options.include ? options.include.split(',') : undefined, excludePatterns: options.exclude ? options.exclude.split(',') : undefined }; const analyzer = new SymbolReferenceAnalyzer(analyzerOptions); const unreferenced = analyzer.checkFile(file); OutputFormatter.displayUnreferencedSymbols(file, unreferenced); } catch (error) { console.error(`エラー: ${error.message}`); process.exit(1); } } } //# sourceMappingURL=DeadCommand.js.map