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

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

Open
Buzzkill-McSquare opened this issue Feb 8, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@Buzzkill-McSquare
Copy link

Buzzkill-McSquare commented Feb 8, 2021

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

  • kea-typegen version: ^0.5.1
  • kea version: ^2.2.2
  • typescript version: ^4.1.2
@Buzzkill-McSquare Buzzkill-McSquare added the bug Something isn't working label Feb 8, 2021
@mariusandra
Copy link
Member

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.

  • What OS are you using? I have only tested this on a Mac OS and Linux myself.
  • What Node version are you using? It should support the recursive: true option in fs.mkdirSync

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
Copy link
Author

@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
Copy link

danielmariz commented May 11, 2021

@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 

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

No branches or pull requests

3 participants