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

on Windows, path returned by process.cwd() breaks the path parser #302

Closed
BWsix opened this issue Aug 10, 2022 · 2 comments
Closed

on Windows, path returned by process.cwd() breaks the path parser #302

BWsix opened this issue Aug 10, 2022 · 2 comments
Labels
🐞 confirmed bug Something isn't working

Comments

@BWsix
Copy link
Contributor

BWsix commented Aug 10, 2022

Describe the bug

// If the user ran `npx create-t3-app .` or similar, the appName should be the current directory
if (appName === ".") {
appName = process.cwd().split("/").pop();
}

On windows, process.cwd() returns something like: D:\\path\\to\\project, which breaks the above code since it uses \\ instead of / to separate efferent segments of path.
Consequently, project generated by create t3 app will use an invalid app name:
image

Steps To Reproduce

  1. (on any windows computer i guess) npx create-t3-app .
  2. see package.json

Possible Solution

Use nodejs's builtin path module to parse the path returned by process.cwd():

  // If the user ran `npx create-t3-app .` or similar, the appName should be the current directory
  if (appName === ".") {
    const parsedCwd = pathModule.resolve(process.cwd());
    appName = pathModule.basename(parsedCwd);
  }
@BWsix
Copy link
Contributor Author

BWsix commented Aug 10, 2022

I made a working patch (not tested on devices other than Windows 10 yet tho) on my fork: link
Would you accept a PR?

@nexxeln
Copy link
Member

nexxeln commented Aug 10, 2022

Yeah sure make a PR we'll take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 confirmed bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants