1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Auto update of new commands from redis.io (Dave Hoover)

Run this: node generate_commands.js

To fetch redis.io/commands.json and save it to a file that node_redis will read at startup.
This commit is contained in:
Matt Ranney
2011-06-12 14:25:57 -10:00
parent d6b5e8b7d3
commit 3d36711563
5 changed files with 46 additions and 41 deletions

View File

@@ -529,15 +529,16 @@ Some people have have added features and fixed bugs in `node_redis` other than m
In order of first contribution, they are: In order of first contribution, they are:
* [Tim Smart](http://github.com/Tim-Smart) * [Tim Smart](https://github.com/Tim-Smart)
* [TJ Holowaychuk](http://github.com/visionmedia) * [TJ Holowaychuk](https://github.com/visionmedia)
* [Rick Olson](http://github.com/technoweenie) * [Rick Olson](https://github.com/technoweenie)
* [Orion Henry](http://github.com/orionz) * [Orion Henry](https://github.com/orionz)
* [Hank Sims](http://github.com/hanksims) * [Hank Sims](https://github.com/hanksims)
* [Aivo Paas](http://github.com/aivopaas) * [Aivo Paas](https://github.com/aivopaas)
* [Paul Carey](https://github.com/paulcarey) * [Paul Carey](https://github.com/paulcarey)
* [Pieter Noordhuis](https://github.com/pietern) * [Pieter Noordhuis](https://github.com/pietern)
* [Vladimir Dronnikov](https://github.com/dvv) * [Vladimir Dronnikov](https://github.com/dvv)
* [Dave Hoover](https://github.com/redsquirrel)
Thanks. Thanks.

View File

@@ -1,6 +1,8 @@
Changelog Changelog
========= =========
Auto update of new commands from redis.io (Dave Hoover)
## v0.6.0 - April 21, 2011 ## v0.6.0 - April 21, 2011
Lots of bugs fixed. Lots of bugs fixed.

View File

@@ -2,38 +2,39 @@ var http = require("http"),
sys = require("sys"), sys = require("sys"),
fs = require("fs"); fs = require("fs");
http.get({host: "redis.io", path: "/commands.json"}, function(res) { function prettyCurrentTime() {
console.log("Response from redis.io/commands.json: " + res.statusCode); var date = new Date();
return date.toLocaleString();
}
var commandString = ""; function write_file(commands, path) {
res.on('data', function(chunk) { var file_contents, out_commands;
commandString += chunk;
console.log("Writing " + Object.keys(commands).length + " commands to " + path);
file_contents = "// This file was generated by ./generate_commands.js on " + prettyCurrentTime() + "\n";
out_commands = Object.keys(commands).map(function (key) {
return key.toLowerCase();
}); });
res.on('end', function() { file_contents += "exports.Commands = " + JSON.stringify(out_commands, null, " ") + ";\n";
var commands = JSON.parse(commandString);
writeCommandsToFile(commands, "lib/commands.js"); fs.writeFile(path, file_contents);
}) }
}).on('error', function(e) {
console.log("Got error: " + e.message); http.get({host: "redis.io", path: "/commands.json"}, function (res) {
var body = "";
console.log("Response from redis.io/commands.json: " + res.statusCode);
res.on('data', function (chunk) {
body += chunk;
});
res.on('end', function () {
write_file(JSON.parse(body), "lib/commands.js");
});
}).on('error', function (e) {
console.log("Error fetching command list from redis.io: " + e.message);
}); });
function writeCommandsToFile(commands, path) {
console.log("Writing " + path);
var fileContents = "// This file was generated by ./generate_commands.js on " + prettyCurrentTime() + "\n";
var lowerCommands = [];
for (var command in commands) {
lowerCommands.push(command.toLowerCase());
}
fileContents += "exports.Commands = " + JSON.stringify(lowerCommands, null, " ") + ";\n";
fs.writeFile(path, fileContents);
}
function prettyCurrentTime() {
var date = new Date();
return date.toLocaleString();
}

View File

@@ -1,4 +1,4 @@
// This file was generated by ./generate_commands.js on Thu Jun 02 2011 21:50:36 GMT-0500 (CDT) // This file was generated by ./generate_commands.js on Sun Jun 12 2011 14:25:05 GMT-1000 (HST)
exports.Commands = [ exports.Commands = [
"append", "append",
"auth", "auth",

View File

@@ -12,7 +12,8 @@
"Paul Carey", "Paul Carey",
"Pieter Noordhuis", "Pieter Noordhuis",
"Andy Ray", "Andy Ray",
"Vladimir Dronnikov" "Vladimir Dronnikov",
"Dave Hoover"
], ],
"main": "./index.js", "main": "./index.js",
"scripts": { "scripts": {