Skip to content

Commit 703eb0d

Browse files
committed
refactor(cli): move dynamic imports to top of index.tsx
- Import fs and path modules at the top instead of dynamic await import() - Use fs.promises for getProjectFileTree call - Cleaner code structure following standard import patterns
1 parent bb52e76 commit 703eb0d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cli/src/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env bun
22

3-
import { promises as fs } from 'fs'
3+
import fs from 'fs'
44
import { createRequire } from 'module'
55
import os from 'os'
6+
import path from 'path'
67

78
import { AnalyticsEvent } from '@codebuff/common/constants/analytics-events'
89
import { getProjectFileTree } from '@codebuff/common/project-file-tree'
@@ -266,7 +267,7 @@ async function main(): Promise<void> {
266267
if (root) {
267268
const tree = await getProjectFileTree({
268269
projectRoot: root,
269-
fs: fs,
270+
fs: fs.promises,
270271
})
271272
logger.info({ tree }, 'Loaded file tree')
272273
setFileTree(tree)
@@ -288,9 +289,6 @@ async function main(): Promise<void> {
288289
process.chdir(newProjectPath)
289290

290291
// Track directory change (avoid logging full paths for privacy)
291-
// Use existsSync to check if .git exists in the new path
292-
const fs = await import('fs')
293-
const path = await import('path')
294292
const isGitRepo = fs.existsSync(path.join(newProjectPath, '.git'))
295293
const pathDepth = newProjectPath.split(path.sep).filter(Boolean).length
296294
trackEvent(AnalyticsEvent.CHANGE_DIRECTORY, {

0 commit comments

Comments
 (0)