Repository navigation
fix(termui): address #3384 β create-termui-app no-overwrite #3387
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
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 |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
|
|
||
| import { dirname, resolve, join } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { mkdirSync, writeFileSync, existsSync, readFileSync } from 'node:fs'; | ||
| import { mkdirSync, writeFileSync, existsSync, readFileSync, readdirSync } from 'node:fs'; | ||
| import { getBuiltinThemeNames } from '@termuijs/tss'; | ||
| import { textPrompt, selectPrompt, multiSelectPrompt } from './prompts.js'; | ||
| import { generateProject, type ProjectConfig } from './templates.js'; | ||
|
|
@@ -122,6 +122,17 @@ async function runProjectScaffold(args: CliArgs): Promise<void> { | |
| // ββ Generate project ββ | ||
| const projectDir = resolve(process.cwd(), projectName); | ||
| if (existsSync(projectDir)) { | ||
| try { | ||
| const entries = fs.readdirSync(projectDir); | ||
| const hasContent = entries.some(e => e !== '.git'); | ||
| if (hasContent) { | ||
| console.log(`\n β Directory "${projectName}" is not empty. Refusing to overwrite.\n`); | ||
| console.log(` Remove the directory or choose a different name.\n`); | ||
|
Comment on lines
+129
to
+130
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. π Maintainability & Code Quality | π Major | β‘ Quick win Use the approved output and Unicode capability handling. The new branch calls As per coding guidelines, π€ Prompt for AI AgentsSource: Coding guidelines |
||
| return; | ||
| } | ||
| } catch { | ||
| // readdirSync failed β let the write calls fail naturally | ||
| } | ||
|
Comment on lines
+133
to
+135
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. ποΈ Data Integrity & Integration | π Major | ποΈ Heavy lift Fail closed when directory inspection fails. This catch block continues to generation after π€ Prompt for AI Agents |
||
| console.log(`\n β Directory "${projectName}" already exists. Files may be overwritten.\n`); | ||
| } | ||
|
|
||
|
|
||
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.
π― Functional Correctness | π΄ Critical | β‘ Quick win
Use the imported
readdirSyncbinding.Line 7 imports
readdirSync, but Line 126 uses an undeclaredfsnamespace. This causes the TypeScript build to fail. CallreaddirSync(projectDir), or import the namespace explicitly.Proposed fix
Also applies to: 126-126
π€ Prompt for AI Agents