-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: expand tilde in configDir before fs calls when adding account #1892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,7 +10,7 @@ import { terminalNameGenerator } from '../terminal-name-generator'; | |||||||||||||||||||||||||||||||||
| import { readSettingsFileAsync } from '../settings-utils'; | ||||||||||||||||||||||||||||||||||
| import { debugLog, } from '../../shared/utils/debug-logger'; | ||||||||||||||||||||||||||||||||||
| import { migrateSession } from '../claude-profile/session-utils'; | ||||||||||||||||||||||||||||||||||
| import { createProfileDirectory } from '../claude-profile/profile-utils'; | ||||||||||||||||||||||||||||||||||
| import { createProfileDirectory, expandHomePath } from '../claude-profile/profile-utils'; | ||||||||||||||||||||||||||||||||||
| import { isValidConfigDir } from '../utils/config-path-validator'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
@@ -161,10 +161,13 @@ export function registerTerminalHandlers( | |||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Ensure config directory exists | ||||||||||||||||||||||||||||||||||
| // Ensure config directory exists (expand ~ before passing to Node.js fs functions, | ||||||||||||||||||||||||||||||||||
| // which do not perform shell tilde expansion) | ||||||||||||||||||||||||||||||||||
| const resolvedConfigDir = expandHomePath(profile.configDir); | ||||||||||||||||||||||||||||||||||
| profile.configDir = resolvedConfigDir; | ||||||||||||||||||||||||||||||||||
| const { mkdirSync, existsSync } = await import('fs'); | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Replace dynamic
♻️ Proposed refactorAt the top of the file, add: +import { existsSync, mkdirSync } from 'fs';Then remove the inline dynamic import: - const { mkdirSync, existsSync } = await import('fs');📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| if (!existsSync(profile.configDir)) { | ||||||||||||||||||||||||||||||||||
| mkdirSync(profile.configDir, { recursive: true }); | ||||||||||||||||||||||||||||||||||
| if (!existsSync(resolvedConfigDir)) { | ||||||||||||||||||||||||||||||||||
| mkdirSync(resolvedConfigDir, { recursive: true }); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+164
to
171
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Synchronous This is an Prefer ⚡ Proposed fix: use async mkdir- const { mkdirSync, existsSync } = await import('fs');
- if (!existsSync(profile.configDir)) {
- mkdirSync(profile.configDir, { recursive: true });
- }
+ const { mkdir } = await import('fs/promises');
+ await mkdir(profile.configDir, { recursive: true });📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
expandHomePathutility is correctly imported here. This is a good practice to centralize path manipulation logic.