jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/401692 )

Change subject: Use Promise.async/yield in tools/fetch-sitematrix.js
......................................................................


Use Promise.async/yield in tools/fetch-sitematrix.js

Also update the sitematrix.

Depends-On: I732ae30a5295f6b1f833553c2293bec8b13ff1c9
Change-Id: I61ae8d09a6a415ec030f95d3a4fc99d2448b676c
---
M tools/fetch-sitematrix.js
1 file changed, 13 insertions(+), 10 deletions(-)

Approvals:
  jenkins-bot: Verified
  Arlolra: Looks good to me, approved



diff --git a/tools/fetch-sitematrix.js b/tools/fetch-sitematrix.js
index 01f3511..ff1b8f3 100755
--- a/tools/fetch-sitematrix.js
+++ b/tools/fetch-sitematrix.js
@@ -9,22 +9,25 @@
 require('../core-upgrade.js');
 
 var Promise = require('../lib/utils/promise.js');
-var fs = require('fs');
+var Util = require('../lib/utils/Util.js').Util;
+
+var fs = require('pn/fs');
 var path = require('path');
 
-var writeFile = Promise.promisify(fs.writeFile, false, fs);
-var request = Promise.promisify(require('request'), true);
 var downloadUrl = 
'https://en.wikipedia.org/w/api.php?action=sitematrix&format=json';
 var filename = path.join(__dirname, '/../lib/config/sitematrix.json');
 
-request({
-       url: downloadUrl,
-       json: true,
-}).spread(function(res, body) {
+Promise.async(function *() {
+       var resp = yield Util.retryingHTTPRequest(1, {
+               url: downloadUrl,
+               json: true,
+       });
+       var res = resp[0];
+       var body = resp[1];
        if (res.statusCode !== 200) {
                throw 'Error fetching sitematrix! Returned ' + res.statusCode;
        }
-       return writeFile(filename, JSON.stringify(body, null, '\t'));
-}).then(function() {
+       yield fs.writeFile(filename, JSON.stringify(body, null, '\t'));
+       console.log('Wrote', filename);
        console.log('Success!');
-}).done();
+})().done();

-- 
To view, visit https://gerrit.wikimedia.org/r/401692
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I61ae8d09a6a415ec030f95d3a4fc99d2448b676c
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: Sbailey <sbai...@wikimedia.org>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to