Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: wrap the projectDir in quotes if it contains spaces #6594

Merged
merged 4 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-beans-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': minor
btea marked this conversation as resolved.
Show resolved Hide resolved
---

wrap projecDir in quptes if it contains spaces
3 changes: 3 additions & 0 deletions packages/create-astro/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ export const nextSteps = async ({ projectDir, devCmd }: { projectDir: string; de

await sleep(100);
if (projectDir !== '') {
if (projectDir.includes(' ')) {
projectDir = `"${projectDir}"`;
}
const enter = [
`\n${prefix}Enter your project directory using`,
color.cyan(`cd ./${projectDir}`, ''),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use a real shell-quoting function like quote(["cd", `./${projectDir}`]) from the shell-quote library, rather than a one-off hack for just one of many shell metacharacters that might be misinterpreted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this only shows a hint of what to do next, and it's unlikely that someone would name their project with $ and ' etc, I think this is enough. It feels overkill to bring in a library for this.

bluwy marked this conversation as resolved.
Show resolved Hide resolved
Expand Down