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

Commit 4991207

Browse files
committed
chore(version-info): make online build compatible with Windows
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)
1 parent 33514ec commit 4991207

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/versions/version-info.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var _ = require('lodash');
99
var process = require('process');
1010
// We are only interested in whether this environment variable exists, hence the !!
1111
var NO_REMOTE_REQUESTS = !!process.env['NG1_BUILD_NO_REMOTE_VERSION_REQUESTS'];
12+
var versionSource = NO_REMOTE_REQUESTS ? 'local' : 'remote';
1213

1314
var currentPackage, previousVersions, cdnVersion, gitRepoInfo;
1415

@@ -149,10 +150,11 @@ var getCdnVersion = function() {
149150
// Note: need to use shell.exec and curl here
150151
// as version-infos returns its result synchronously...
151152
var cdnResult = shell.exec('curl http://ajax.googleapis.com/ajax/libs/angularjs/' + version + '/angular.min.js ' +
152-
'--head --write-out "%{http_code}" -o /dev/null -silent',
153+
'--head --write-out "%{http_code}" -silent',
153154
{silent: true});
154155
if (cdnResult.code === 0) {
155-
var statusCode = cdnResult.output.trim();
156+
// --write-out appends its content to the general request response, so extract it
157+
var statusCode = cdnResult.output.split('\n').pop().trim();
156158
if (statusCode === '200') {
157159
cdnVersion = version;
158160
}
@@ -221,5 +223,6 @@ if (NO_REMOTE_REQUESTS) {
221223
console.log(' - be aware that the generated docs may not have valid or the most recent version information.');
222224
console.log('==============================================================================================');
223225
}
224-
console.log('CDN version:', cdnVersion.raw);
225-
console.log('Current version:', exports.currentVersion.raw);
226+
227+
console.log('CDN version (' + versionSource + '):', cdnVersion ? cdnVersion.raw : 'No version found.');
228+
console.log('Current version (' + versionSource + '):', exports.currentVersion.raw);

0 commit comments

Comments
 (0)