From ccbfc16db5bdcc53c3dd9c6ba6f1d77a202ef0d9 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Tue, 3 Sep 2024 11:17:22 +0800 Subject: [PATCH] chore: remove unnecessary code --- cli/src/prompt.ts | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/cli/src/prompt.ts b/cli/src/prompt.ts index 020c1c21..7d048ea4 100644 --- a/cli/src/prompt.ts +++ b/cli/src/prompt.ts @@ -1,5 +1,4 @@ import process from 'node:process' -import path from 'node:path' import { createRequire } from 'node:module' import { cancel, confirm, group, select, text } from '@clack/prompts' import { setLang, t } from './translate.js' @@ -132,34 +131,3 @@ export async function prompt(mode: Mode, root?: string): Promise { return result } - -export async function getTargetDir(cwd: string, dir?: string) { - if (dir === '.') - return cwd - - if (typeof dir === 'string' && dir) { - return path.resolve(cwd, dir) - } - - const DEFAULT_DIR = 'my-project' - - const dirPath = await text({ - message: t('question.root'), - placeholder: DEFAULT_DIR, - validate(value) { - if (value && REG_DIR_CHAR.test(value)) - return t('hint.root.illegal') - - return undefined - }, - defaultValue: DEFAULT_DIR, - }) - - if (typeof dirPath === 'string') { - if (dirPath === '.') - return cwd - - return path.join(cwd, dirPath || DEFAULT_DIR) - } - return dirPath -}