Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't create directory structure for output file #49

Open
ajbogh opened this issue Jun 29, 2018 · 4 comments
Open

Doesn't create directory structure for output file #49

ajbogh opened this issue Jun 29, 2018 · 4 comments

Comments

@ajbogh
Copy link
Contributor

ajbogh commented Jun 29, 2018

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
Copy link
Contributor Author

ajbogh commented Jun 29, 2018

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

@orta
Copy link
Collaborator

orta commented Jun 30, 2018

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

@ajbogh
Copy link
Contributor Author

ajbogh commented Jun 30, 2018

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
Copy link
Contributor Author

ajbogh commented Jul 3, 2018

PR here: #50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants