keajs / kea-typegen

6 stars 5 forks source link

Watch & Write commands fail if the target directory already exists. #15

Open Buzzkill-McSquare opened 3 years ago

Buzzkill-McSquare commented 3 years ago

Bug description (include screenshots or a GIF screencast)

Using the watch or write commands fail with the following error if the directory identified in the typesPath property of .kearc already exists;

Error: EEXIST: file already exists, mkdir '<directory pointed to in typesPath>'

How to reproduce

  1. Create a new project with the relevant dependencies (everything necessary for kea & kea-typegen)
  2. Run kea-typegen write twice OR create a new type definition, save, modify the type and save again.

Expected behavior

If the directory already exists then existing definitions should be updated and new definitions should be added without any complications.

Environment

mariusandra commented 3 years ago

This is very strange. Updating files without creating a new folder definitely should work. That's in fact the default mode of operation, when we store the type files in the same folder as the logics.

Also, I have recently updated the recommended setup for typegen. While the docs earlier suggested putting all the types in a different folder, I've found it to be a better experience overall if the types are in the same folder, but excluded from git by adding *Type.ts into .gitignore.

Buzzkill-McSquare commented 3 years ago

@mariusandra sorry for this late response. I was working on Windows through an IntelliJ IDE, but I think I was running it through WSL2 using Ubuntu. It's possible that the issue was due to some weird configuration across that boundary.

danielmariz commented 3 years ago

@mariusandra I was wondering if its possible to customize the types folder even more like having a local subfolder and custom name for the types example ./**/__types__/*.types.ts so the structure would look something like:

/logicFolder
  logic.ts
  /__types__
    logic.type.ts