The ouputFile is overwritten while iterating over multiple .d.ts files
I would like to automatically convert typescript files in-place to flow files. I found that I could include multiple typescript files by using a glob pattern, however the output file option seems to only accept a single filename.
When the single output file is generated it only includes the type information for the last file iterated upon.
flowgen ./dist/**/*.d.ts -o ./dist/example.flow.js
The code should either append all types into this single output file, or it should allow a similar Glob pattern and generate flow files based on the same root name (everything before .d.ts).
# concatenate all types to one file
flowgen ./dist/**/*.d.ts -o ./dist/example.flow.js
# create files with similar names and folder structure
flowgen ./dist/**/*.d.ts -o ./dist/**/*.flow.js
https://github.com/joarwilk/flowgen/blob/140e0f0c3c13fe07af63d5ece46c89da93bc76bf/src/cli/runner.js#L61
Workaround:
Add the following code to your package.json
"flowgen": "for file in $(find ./dist -name *.d.ts -type f); do flowgen ${file} -o ${file/.d.ts/.flow.js}; done;"
Run the command with npm run flowgen.
Alternatively, if flowgen is installed globally by npm install -g flowgen then you can use the command directly in the terminal:
for file in $(find ./dist -name *.d.ts -type f); do flowgen ${file} -o ${file/.d.ts/.flow.js}; done;
That makes sense, yeah, would happily take that PR 👍