You've already forked node-redis
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:
@@ -21,19 +21,15 @@ http.get({host: "redis.io", path: "/commands.json"}, function(res) {
|
||||
function writeCommandsToFile(commands, path) {
|
||||
console.log("Writing " + path);
|
||||
|
||||
var fileContents = "// This file was generated by ./generate_commands.js on ";
|
||||
fileContents += prettyCurrentTime();
|
||||
fileContents += "\nCommands = [\n";
|
||||
var fileContents = "// This file was generated by ./generate_commands.js on " + prettyCurrentTime() + "\n";
|
||||
|
||||
var lowerCommands = [];
|
||||
for (var command in commands) {
|
||||
lowerCommands.push(" \"" + command.toLowerCase() + "\"");
|
||||
lowerCommands.push(command.toLowerCase());
|
||||
}
|
||||
|
||||
fileContents += lowerCommands.join(",\n");
|
||||
fileContents += "\n];\n\n"
|
||||
fileContents += "exports.Commands = Commands;"
|
||||
|
||||
fileContents += "exports.Commands = " + JSON.stringify(lowerCommands, null, " ") + ";\n";
|
||||
|
||||
fs.writeFile(path, fileContents);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user