| 12 | |
| 13 | // Create test files for searching |
| 14 | function setupTestFiles() { |
| 15 | console.log('\n📁 Setting up test files...') |
| 16 | |
| 17 | if (!existsSync(testDir)) { |
| 18 | mkdirSync(testDir, { recursive: true }) |
| 19 | } |
| 20 | |
| 21 | writeFileSync( |
| 22 | join(testDir, 'example.js'), |
| 23 | ` |
| 24 | // Test file for ripgrep search |
| 25 | function testFunction() { |
| 26 | console.log('This is a test function'); |
| 27 | const specialPattern = 'UNIQUE_SEARCH_TERM'; |
| 28 | return specialPattern; |
| 29 | } |
| 30 | |
| 31 | module.exports = { testFunction }; |
| 32 | `, |
| 33 | ) |
| 34 | |
| 35 | writeFileSync( |
| 36 | join(testDir, 'example.ts'), |
| 37 | ` |
| 38 | // TypeScript test file |
| 39 | interface TestInterface { |
| 40 | name: string; |
| 41 | value: number; |
| 42 | } |
| 43 | |
| 44 | class TestClass implements TestInterface { |
| 45 | name = 'UNIQUE_SEARCH_TERM'; |
| 46 | value = 42; |
| 47 | } |
| 48 | |
| 49 | export { TestClass }; |
| 50 | `, |
| 51 | ) |
| 52 | |
| 53 | writeFileSync( |
| 54 | join(testDir, 'config.json'), |
| 55 | `{ |
| 56 | "name": "test-config", |
| 57 | "setting": "UNIQUE_SEARCH_TERM", |
| 58 | "enabled": true |
| 59 | }`, |
| 60 | ) |
| 61 | |
| 62 | console.log('✅ Test files created') |
| 63 | } |
| 64 | |
| 65 | // Clean up test files |
| 66 | async function cleanupTestFiles() { |