Skip to content

Add --cafile command line option.#837

Merged
bnoordhuis merged 2 commits intonodejs:masterfrom
bnoordhuis:cafile
Dec 10, 2015
Merged

Add --cafile command line option.#837
bnoordhuis merged 2 commits intonodejs:masterfrom
bnoordhuis:cafile

Conversation

@bnoordhuis
Copy link
Copy Markdown
Member

R=@rvagg?

Comment thread lib/install.js Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taking a cb option that's only used when erroring is a bit gross, perhaps it'd closer to idiomatic if the thrown error bubbled up and the try/catch was done at the download() call?

@rvagg
Copy link
Copy Markdown
Member

rvagg commented Dec 9, 2015

A bit smelly, I understand that it's hard to do much better without a more heavy refactor. Things I don't like:

  • the use of cb only for errors, the fact that it has a cb argument at all in fact
  • the fs.readFileSync() to read the cert file

A begrudging lgtm since I understand the challenges of doing a better job, I would prefer the cb thing be handled but if you feel strongly enough that the way you've implemented it is good enough then go ahead.

Yet another refactor for the future I suppose.

@bnoordhuis
Copy link
Copy Markdown
Member Author

I added a commit that lets the exception bubble up. I'm a bit on the fence on whether it's an improvement; let me know what you think.

@rvagg
Copy link
Copy Markdown
Member

rvagg commented Dec 10, 2015

I'm happy with the clarity of the changes, but generally unhappy with the structure of the call chain but that's a matter for another day! lgtm

Move the function around so it can be tested and add a regression test.

As a policy vs. mechanism thing, change the control flow to handle
exceptions at the call site, not inside the download function.

PR-URL: #837
Reviewed-By: Rod Vagg <[email protected]>
Add an option for overriding the default CA chain that is used when
downloading the tarball.  This matches the npm option of the same
name and gets implicitly passed through the `npm_config_cafile`
environment variable.

Fixes: #695
PR-URL: #837
Reviewed-By: Rod Vagg <[email protected]>
@bnoordhuis bnoordhuis merged commit 8c4b0ff into nodejs:master Dec 10, 2015
@bnoordhuis bnoordhuis deleted the cafile branch December 10, 2015 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants