Skip to content

Instantly share code, notes, and snippets.

@johnywith1n
Created December 14, 2015 21:41
Show Gist options
  • Save johnywith1n/bb5f2213189367462fa2 to your computer and use it in GitHub Desktop.
Save johnywith1n/bb5f2213189367462fa2 to your computer and use it in GitHub Desktop.
check for 6.86 patch
'use strict';
var Promise = require('bluebird');
var request = Promise.promisifyAll(require('request'));
var open = require('open');
var FOUND = false;
function promiseWhile(predicate, action) {
function loop() {
if (!predicate()) return;
return Promise.resolve(action()).then(loop);
}
return Promise.resolve().then(loop);
}
var createResponsePromise = function () {
return request.getAsync('http://blog.dota2.com/');
}
promiseWhile(function () {
return !FOUND;
}, function () {
console.log('checking dota 2 blog at ' + new Date());
return createResponsePromise().then(function (res) {
if (res.body.indexOf('6.86') > -1) {
FOUND = true;
console.log('6.86 IS HERE!!!!');
open('http://blog.dota2.com/')
}
}).catch(function (e) {
console.error(e);
}).delay(60*1000);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment