Doesn't create directory structure for output file
flowgen doesn't seem to create non-existent directories when one is provided in the output file. It should create all directories up to the filename, or provide an option to do so.
For instance, I do not yet have a flow-typed folder, so this command fails:
$ flowgen ${file} -o ./flow-typed/test.flow.js;
{ Error: ENOENT: no such file or directory, open './flow-typed/test.flow.js'
A workaround to the above is to use a Bash command and add it to your package.json as a script. Using an example from #48, I've added the new outfile variable and included a mkdir command using dirname. This ensures that the directory is created and that all files are placed in the flow-typed folder in the same directory structure as the original src directory.
Command line:
for file in $(find ./dist -name *.d.ts -type f); do outfile=${file/.\/dist\//.\/flow-typed/} && mkdir -p `dirname $outfile` && flowgen ${file} -o ${outfile/.d.ts/.flow.js}; done;
package.json:
"flowgen": "for file in $(find ./dist -name *.d.ts -type f); do outfile=${file/.\\/dist\\//.\\/flow-typed/} && mkdir -p `dirname $outfile` && flowgen $file -o ${outfile/.d.ts/.flow.js}; done;"
Probably worth trying to make a PR instead at this point 👍
Thanks. I'll be making some PRs in the next few days, please help me by reviewing them as quickly as you can. I'd be happy to help out.
PR here: https://github.com/joarwilk/flowgen/pull/50