MCPcopy Create free account
hub / github.com/vercel/vercel / inputRootDirectory

Function inputRootDirectory

packages/cli/src/util/input/input-root-directory.ts:7–48  ·  view source on GitHub ↗
(
  client: Client,
  cwd: string,
  autoConfirm = false
)

Source from the content-addressed store, hash-verified

5import type Client from '../client';
6
7export async function inputRootDirectory(
8 client: Client,
9 cwd: string,
10 autoConfirm = false
11) {
12 if (autoConfirm) {
13 return null;
14 }
15
16 while (true) {
17 const rootDirectory = await client.input.text({
18 message: `Code directory?`,
19 transformer: (input: string) => {
20 return `${chalk.dim(`./`)}${input}`;
21 },
22 });
23
24 if (!rootDirectory) {
25 return null;
26 }
27
28 const normal = path.normalize(rootDirectory);
29
30 if (normal === '.' || normal === './') {
31 return null;
32 }
33
34 const fullPath = path.join(cwd, normal);
35
36 if (
37 (await validateRootDirectory(
38 cwd,
39 fullPath,
40 'Please choose a different one.'
41 )) === false
42 ) {
43 continue;
44 }
45
46 return normalizePath(normal);
47 }
48}

Callers 2

setupAndLinkFunction · 0.90

Calls 5

validateRootDirectoryFunction · 0.90
normalizePathFunction · 0.90
textMethod · 0.80
normalizeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected