Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

chore(version-info.js): ignore curl file write errors #14780

Merged
merged 2 commits into from
Jun 15, 2016

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Jun 15, 2016

On Windows, curl can obviously not write to dev/null, and throws code 23, which prevents us from checking that the CDN server responded. However, we don't need the file anyway, we just need the status code, so we can ignore the file write error.

This needs to be tested on Linux / Mac however!

if (cdnResult.code === 0) {
// Ignore if Curl can't write the file (code 23), e.g. on Windows, as we still get
// the needed output from --write-out
if (cdnResult.code === 0 || cdnResult.code === 23) {
var statusCode = cdnResult.output.trim();
Copy link
Contributor

Choose a reason for hiding this comment

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

Really we only care about whether requests to this URL are 404 or not, right?

Why don't we ditch the curl altogether and just use the http library?

https://nodejs.org/dist/latest-v4.x/docs/api/http.html#http_http_request_options_callback

@Narretz Narretz merged commit 915e7a1 into angular:master Jun 15, 2016
Narretz added a commit that referenced this pull request Jun 16, 2016
Since we cannot write to dev/null on Windows, don't write to a file at all, but simply use stdout and extract the output from --write-out from the process response. Credit to @petebacondarwin for the idea.

The commit also avoids a premature error when no cdnVersion could be found online, and improves the log wrt the origin of the versions.

PR (#14780)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants