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

Simplifying writeCommandsToFile /ht @polgfred

This commit is contained in:
Dave Hoover
2011-06-02 21:52:03 -05:00
parent e210755b52
commit e6b29c6846
2 changed files with 6 additions and 12 deletions

View File

@@ -21,19 +21,15 @@ http.get({host: "redis.io", path: "/commands.json"}, function(res) {
function writeCommandsToFile(commands, path) { function writeCommandsToFile(commands, path) {
console.log("Writing " + path); console.log("Writing " + path);
var fileContents = "// This file was generated by ./generate_commands.js on "; var fileContents = "// This file was generated by ./generate_commands.js on " + prettyCurrentTime() + "\n";
fileContents += prettyCurrentTime();
fileContents += "\nCommands = [\n";
var lowerCommands = []; var lowerCommands = [];
for (var command in commands) { for (var command in commands) {
lowerCommands.push(" \"" + command.toLowerCase() + "\""); lowerCommands.push(command.toLowerCase());
} }
fileContents += lowerCommands.join(",\n"); fileContents += "exports.Commands = " + JSON.stringify(lowerCommands, null, " ") + ";\n";
fileContents += "\n];\n\n"
fileContents += "exports.Commands = Commands;"
fs.writeFile(path, fileContents); fs.writeFile(path, fileContents);
} }

View File

@@ -1,5 +1,5 @@
// This file was generated by ./generate_commands.js on Thu Jun 02 2011 21:09:35 GMT-0500 (CDT) // This file was generated by ./generate_commands.js on Thu Jun 02 2011 21:50:36 GMT-0500 (CDT)
Commands = [ exports.Commands = [
"append", "append",
"auth", "auth",
"bgrewriteaof", "bgrewriteaof",
@@ -124,5 +124,3 @@ Commands = [
"zscore", "zscore",
"zunionstore" "zunionstore"
]; ];
exports.Commands = Commands;