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)
This commit is contained in:
@@ -9,6 +9,7 @@ var _ = require('lodash');
|
||||
var process = require('process');
|
||||
// We are only interested in whether this environment variable exists, hence the !!
|
||||
var NO_REMOTE_REQUESTS = !!process.env['NG1_BUILD_NO_REMOTE_VERSION_REQUESTS'];
|
||||
var versionSource = NO_REMOTE_REQUESTS ? 'local' : 'remote';
|
||||
|
||||
var currentPackage, previousVersions, cdnVersion, gitRepoInfo;
|
||||
|
||||
@@ -149,10 +150,11 @@ var getCdnVersion = function() {
|
||||
// Note: need to use shell.exec and curl here
|
||||
// as version-infos returns its result synchronously...
|
||||
var cdnResult = shell.exec('curl http://ajax.googleapis.com/ajax/libs/angularjs/' + version + '/angular.min.js ' +
|
||||
'--head --write-out "%{http_code}" -o /dev/null -silent',
|
||||
'--head --write-out "%{http_code}" -silent',
|
||||
{silent: true});
|
||||
if (cdnResult.code === 0) {
|
||||
var statusCode = cdnResult.output.trim();
|
||||
// --write-out appends its content to the general request response, so extract it
|
||||
var statusCode = cdnResult.output.split('\n').pop().trim();
|
||||
if (statusCode === '200') {
|
||||
cdnVersion = version;
|
||||
}
|
||||
@@ -221,5 +223,6 @@ if (NO_REMOTE_REQUESTS) {
|
||||
console.log(' - be aware that the generated docs may not have valid or the most recent version information.');
|
||||
console.log('==============================================================================================');
|
||||
}
|
||||
console.log('CDN version:', cdnVersion.raw);
|
||||
console.log('Current version:', exports.currentVersion.raw);
|
||||
|
||||
console.log('CDN version (' + versionSource + '):', cdnVersion ? cdnVersion.raw : 'No version found.');
|
||||
console.log('Current version (' + versionSource + '):', exports.currentVersion.raw);
|
||||
|
||||
Reference in New Issue
Block a user