Skip to content

Commit 8c61a38

Browse files
authored
better create into cwd (#1701)
1 parent 83d21f2 commit 8c61a38

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/create.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ export async function create(effects: CreateEffects = defaultEffects): Promise<v
5959
appTitle: ({results: {rootPath}}) =>
6060
clack.text({
6161
message: "What should we title your app?",
62-
placeholder: inferTitle(rootPath!),
63-
defaultValue: inferTitle(rootPath!)
62+
placeholder: inferTitle(rootPath),
63+
defaultValue: inferTitle(rootPath)
6464
}),
6565
includeSampleFiles: () =>
6666
clack.select({
@@ -135,7 +135,10 @@ export async function create(effects: CreateEffects = defaultEffects): Promise<v
135135
}
136136
}
137137
if (spinning) s.stop("Installed! 🎉");
138-
const instructions = [`cd ${rootPath}`, ...(packageManager ? [] : [installCommand]), `${runCommand} dev`];
138+
const instructions: string[] = [];
139+
if (rootPath !== ".") instructions.push(`cd ${rootPath}`);
140+
if (!packageManager) instructions.push(installCommand);
141+
instructions.push(`${runCommand} dev`);
139142
clack.note(instructions.map((line) => reset(cyan(line))).join("\n"), "Next steps…");
140143
clack.outro(`Problems? ${link("https://github.com/observablehq/framework/discussions")}`);
141144
}
@@ -159,8 +162,8 @@ function validateRootPath(rootPath: string, defaultError?: string): string | und
159162
if (readdirSync(rootPath).length !== 0) return "Directory is not empty.";
160163
}
161164

162-
function inferTitle(rootPath: string): string {
163-
return basename(rootPath!)
165+
function inferTitle(rootPath = "."): string {
166+
return basename(join(process.cwd(), rootPath))
164167
.split(/[-_\s]/)
165168
.map(([c, ...rest]) => c.toUpperCase() + rest.join(""))
166169
.join(" ");

0 commit comments

Comments
 (0)