castle icon indicating copy to clipboard operation
castle copied to clipboard

avro-ts-cli: Wildcard search for files doesn't work

Open lajtmaN opened this issue 4 years ago • 4 comments

When running the CLI using wildcard for finding avro files, it fails.

$ avro-ts avro-files/*.avsc
Converting Avro to TypeScript

internal/fs/utils.js:230
    throw err;
    ^

Error: ENOENT: no such file or directory, open 'avro-files/*.avsc'
    at Object.openSync (fs.js:457:3)
    at Object.readFileSync (fs.js:359:35)
    at %AppData%\Roaming\npm\node_modules\@ovotech\avro-ts-cli\dist\convert.js:72:55
    at Array.map (<anonymous>)

If I take one file at a time it works fine.

I'm running on Windows.

lajtmaN avatar Jun 10 '20 06:06 lajtmaN

Oh dear yeah that might be an issue for Windows. in Linux/Mac if you do avro-ts avro-files/*.avsc what the command underneath actually receives is avro-ts avro-files/file1.avsc avro-files/file2.avsc avro-files/file3.avsc kind of thing. As a work around you might do that for the time being, until I can come up with a way to do it on windows. Another option is WSL, which should have all those bash goodies baked in.

ivank avatar Jun 10 '20 09:06 ivank

For now, I have wrapped it in a shell script that gets all files and then runs them one by one. But you could look at something like glob to get the files.

lajtmaN avatar Jun 11 '20 06:06 lajtmaN

Hey :wave: . Not directly related to the original issue, but supporting a double-star ** could be a nice addition also, when there are multiple directories containing avro files.

avro-ts avro-files/**/*.avsc

pylebecq avatar Jul 30 '20 13:07 pylebecq

I'm kind of reluctant to add support for that inside of node itself, mainly because the libraries usually bring an ungodly number of dependencies themselves. Though I might just add the one that's most popular as you would be having it anyway, and it would only be for the CLI package.

avro-ts avro-files/**/*.avsc

Already works in most shells anyway.

ivank avatar Aug 03 '20 06:08 ivank