snaerth / create-react-component-folder

Creates react component folder structure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested folders not working in windows

socrat3z opened this issue · comments

Having the latest package installed, while trying to create Button component on Windows with the following syntax
crcf components/Button
the "Button" folder is created in root, and not in the "components" folder

Thank you for pointing that out. I will fix it in the to night or tomorrow and let you know :)

@socrat3z What Node version are you running?

@snaerth it's v9.5.0

@snaerth After skimming through the code I believe the issue lies in

function getComponentParentFolder(componentPath) {
  if (componentPath !== -1) {
    return componentPath.substring(0, componentPath.lastIndexOf(lastSlash) + 1);
  }

  return componentPath;
}

Specifically if (componentPath !== -1) {
Shouldn't that be if(componentPath.lastIndexOf(lastSlash) !== -1)

That fixes the issue with an initialisation of component/Button but breaks it for Button.
It produces a folder called "ButtonButton"

Edit
My node version is v8.9.4

Thank you @Aidurber for pointing it out. I am a little busy today but I promise to find a permanent solution tomorrow and fix the issue for good.

I have fixed the windows issue in version 0.0.35. Can you @Aidurber and @socrat3z confirm :)

issue can be reproduced for 0.1.0

Hi, I have this issue on Windows 10 as well. I ran on the Ubuntu shell included with Windows - Windows Subsystem for Linux - and it creates the module in the sub-path correctly, but when ran from Windows command shell, it creates the component folder in the CWD. I need it to work on the command shell because I'm running from the terminal in VS Code.

Doesn't happen for me as well. It creates the component in whatever folder I am in. Doesn't respect the folder path I provide.