-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73fe7f8
commit 39280ad
Showing
6 changed files
with
88 additions
and
34 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { PromptObject } from 'prompts' | ||
import { bold, red } from 'kolorist' | ||
import figures from 'prompts/lib/util/figures.js' | ||
import { canSkipEmptying } from '../utils' | ||
|
||
export default (targetDir: string): PromptObject<string>[] => { | ||
return [ | ||
{ | ||
name: 'shouldOverwrite', | ||
type: () => (canSkipEmptying(targetDir) ? null : 'toggle'), | ||
message: () => { | ||
const dirForPrompt | ||
= targetDir === '.' ? '当前文件' : `目标文件"${targetDir}"` | ||
|
||
return `${dirForPrompt}不是空的。要删除现有文件并继续吗?` | ||
}, | ||
initial: false, | ||
active: 'Yes', | ||
inactive: 'No', | ||
}, | ||
{ | ||
name: 'overwriteChecker', | ||
type: (_prev, values) => { | ||
if (values.shouldOverwrite === false) | ||
throw new Error(`${red(figures.cross)} ${bold('操作已取消')}`) | ||
|
||
return null | ||
}, | ||
}, | ||
] | ||
} |
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