(f)
| 176 | } |
| 177 | |
| 178 | function gitHubResponse(f) { |
| 179 | var msg = ""; |
| 180 | |
| 181 | return function(res) { |
| 182 | |
| 183 | console.log(); |
| 184 | |
| 185 | var nlTerminate = false; |
| 186 | if (res.headers['x-ratelimit-limit']) { |
| 187 | console.log("Rate limit: " + res.headers['x-ratelimit-limit']); |
| 188 | nlTerminate = true; |
| 189 | } |
| 190 | if (res.headers['x-ratelimit-remaining']) { |
| 191 | console.log("Rate remaining: " + res.headers['x-ratelimit-remaining']); |
| 192 | nlTerminate = true; |
| 193 | } |
| 194 | if (res.headers['x-ratelimit-reset']) { |
| 195 | console.log("Rate will reset: " + new Date(res.headers['x-ratelimit-reset'] * 1000)); |
| 196 | nlTerminate = true; |
| 197 | } |
| 198 | |
| 199 | if (nlTerminate) { |
| 200 | console.log(); |
| 201 | } |
| 202 | |
| 203 | res.on('data', function (d) { |
| 204 | msg += d; |
| 205 | }); |
| 206 | res.on('end', function (d) { |
| 207 | |
| 208 | var data = JSON.parse(msg); |
| 209 | if (data.message) { |
| 210 | console.log("Message:\n" + data.message + "\n"); |
| 211 | } |
| 212 | if (data.documentation_url) { |
| 213 | console.log("Documentation:\n" + data.documentation_url + "\n"); |
| 214 | } |
| 215 | |
| 216 | f(data); |
| 217 | }); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | function getPassword(callback) { |
| 222 | process.stdout.write("Password: "); |
no test coverage detected