flowgen icon indicating copy to clipboard operation
flowgen copied to clipboard

Doesn't create directory structure for output file

Open ajbogh opened this issue 7 years ago • 4 comments

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'

ajbogh avatar Jun 29 '18 22:06 ajbogh

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;"

ajbogh avatar Jun 29 '18 22:06 ajbogh

Probably worth trying to make a PR instead at this point 👍

orta avatar Jun 30 '18 00:06 orta

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.

ajbogh avatar Jun 30 '18 01:06 ajbogh

PR here: https://github.com/joarwilk/flowgen/pull/50

ajbogh avatar Jul 03 '18 17:07 ajbogh