Types are not generated on the first run. No such file or directory
I am running sqlx-ts for the first time; the type file does not exist yet, and the types are being generated. The file already exists, and the types need to be updated. After running the command "command", the file is deleted, and an error occurs:
$ sqlx-ts ./src/model/ -g --config .sqlxrc.json --generate-path ./src/model/types.ts
[INFO] Scanning "./src/model/" for SQLs with extension Ts
thread 'main' panicked at src/parser/mod.rs:133:45:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error Command failed with exit code 101.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Process finished with exit code 101
But on re-running the command, the file is created again, and the types are generated again.
Thanks for reporting, that is strange - I will take a look soon. Can you try without --generate-path in the meantime?
Unfortunately, i can't(
@Leo5878 hello, I'm trying to reproduce this issue.
I am trying multiple ways to run sqlx-ts based on your explanations
- for
generate-path, when I give it a file path that does not exist yet (for example./tests/stagingz/hello.types.ts). I can see it correctly creates the non-existing folder and the type definition under the folder as well. - I am only seeing the same error in the issue if I provide a wrong
path to typescript or javascript project^^^ in this example, I am intentionally providing
./tests/stagingzwhich does not exist
If this is the case, I can go ahead and enhance the error message when you provide a project path that does not exist
Actually nvm, we already have the a line to check for an empty project here https://github.com/JasonShin/sqlx-ts/blob/main/src/main.rs#L49
This is now released as 0.12.1 https://github.com/JasonShin/sqlx-ts/releases/tag/v0.12.1
@JasonShin Hi! No, that's not quite right. According to my tests, the level of nesting somehow affects this issue. I couldn't understand why, but during debugging, I noticed that scanfolder returns the file specified in generate-path, not all the files with the .ts extension in the folder. After running it again, it returns all the files. Somehow, my PR managed to fix this problem. I will try to study the issue further in the future if I have the opportunity.
Thank you for accepting my PR!
Thanks, I have added my thought in https://github.com/JasonShin/sqlx-ts/pull/114, thanks for this