-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(commands): do not ask to remove existing directory when non-inter…
…active
- Loading branch information
1 parent
88fd2be
commit 0728ea9
Showing
3 changed files
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'create-expo-stack': patch | ||
--- | ||
|
||
fix: do not ask to remove existing directory when non-interactive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import { ExistsResult } from 'fs-jetpack/types'; | ||
import { GluegunPrompt } from 'gluegun'; | ||
|
||
export async function validateProjectName(exists: (path: string) => ExistsResult, removeAsync: (path?: string) => Promise<void>, prompt: GluegunPrompt, projectName: string): Promise<void> { | ||
if (exists(projectName)) { | ||
export async function validateProjectName(exists: (path: string) => ExistsResult, removeAsync: (path?: string) => Promise<void>, prompt: GluegunPrompt | null, projectName: string): Promise<void> { | ||
if (!exists(projectName)) { | ||
return; | ||
} | ||
|
||
if (prompt != null) { | ||
const confirmDelete = await prompt.ask([ | ||
{ | ||
type: 'confirm', | ||
name: 'delete', | ||
message: `A folder with the name '${projectName}' already exists. Do you want to delete it?` | ||
}, | ||
]); | ||
|
||
if (confirmDelete.delete) { | ||
await removeAsync(projectName); | ||
console.log(`Deleted existing directory: ${projectName}`); | ||
} else { | ||
throw new Error(`Exiting, a project with the name '${projectName}' already exists.`); | ||
return void console.log(`Deleted existing directory: ${projectName}`); | ||
} | ||
} | ||
|
||
throw new Error(`A project with the name '${projectName}' already exists.`); | ||
} |
0728ea9
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.
Successfully deployed to the following URLs:
create-expo-stack-docs – ./docs
docs.createexpostack.com
docs.expostack.dev
create-expo-stack-docs-git-main-ronin-tech.vercel.app
create-expo-stack-docs-ronin-tech.vercel.app