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

Use custom template by url #49

Closed
KaiSchwarz-cnic opened this issue Jul 3, 2018 · 1 comment
Closed

Use custom template by url #49

KaiSchwarz-cnic opened this issue Jul 3, 2018 · 1 comment

Comments

@KaiSchwarz-cnic
Copy link

KaiSchwarz-cnic commented Jul 3, 2018

Hey Pete,

I wrote some custom templates, that I want to reuse over several projects.
Therefore I added them to a public github repository.

Allowing to provide the template by url, would help a lot. e.g. https://raw.githubusercontent.com/...
Otherwise I would have to 1st save the template locally by using wget / curl or so, then generating the changelog and finally deleting the template again.

As the methods you use from fs package already support handling an URL, I expect just a minor modification in your code: trying to instantiate an URL Object from given template string.
https://nodejs.org/api/url.html#url_the_whatwg_url_api
So having a try catch around and if the above fails, just continue with the previous value.
I try to provide a PR.

Or do you have another approach?

@KaiSchwarz-cnic
Copy link
Author

KaiSchwarz-cnic commented Jul 3, 2018

fyi - i just stumbled over that notice in the nodejs fs api
https://nodejs.org/api/fs.html#fs_fs_access_path_mode_callback

Using fs.access() to check for the accessibility of a file before calling fs.open(), fs.readFile() or fs.writeFile() is not recommended. Doing so introduces a race condition, since other processes may change the file's state between the two calls. Instead, user code should open/read/write the file directly and handle the error raised if the file is not accessible.

It might work for your case - no question, just wanted to forward this to you in addition.

b6pzeusbc54tvhw5jgpyw8pwz2x6gs pushed a commit to b6pzeusbc54tvhw5jgpyw8pwz2x6gs/auto-changelog that referenced this issue Sep 19, 2018
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

1 participant