1 var http = require("http"),
4 function prettyCurrentTime() {
6 return date.toLocaleString();
9 function write_file(commands, path) {
10 var file_contents, out_commands;
12 console.log("Writing " + Object.keys(commands).length + " commands to " + path);
14 file_contents = "// This file was generated by ./generate_commands.js on " + prettyCurrentTime() + "\n";
16 out_commands = Object.keys(commands).map(function (key) {
17 return key.toLowerCase();
20 file_contents += "module.exports = " + JSON.stringify(out_commands, null, " ") + ";\n";
22 fs.writeFile(path, file_contents);
25 http.get({host: "redis.io", path: "/commands.json"}, function (res) {
28 console.log("Response from redis.io/commands.json: " + res.statusCode);
30 res.on('data', function (chunk) {
34 res.on('end', function () {
35 write_file(JSON.parse(body), "lib/commands.js");
37 }).on('error', function (e) {
38 console.log("Error fetching command list from redis.io: " + e.message);