this function seems like it does quite a few things. 

I propose splitting out this file into its own helper, so that you could break the complexity of this function down quite a bit.

Such as 

```
fetchGitUrl
generateTemplateError
lookupTemplatePath
```


This will make debugging this much easier and will also maintain small single intent functions that will improve readability and maintainability.