Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 962dd7c
Showing
13 changed files
with
420 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
node_modules/ | |||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,42 @@ | |||
|
|||
fs = require 'fs' | |||
findit = require 'findit' | |||
exec = require('child_process').exec | |||
coffee = require 'coffee-script' | |||
path = require 'path' | |||
|
|||
escapeShell = (arg) -> "'" + arg.replace(/[^\\]'/g, (m, i, s) -> m.slice(0, 1) + "\\'") + "'" | |||
src = __dirname + '/src' | |||
bin = __dirname + '/bin' | |||
|
|||
task 'build', 'build project', (options) -> | |||
|
|||
# Remove bin contents | |||
exec "rm -rf #{escapeShell bin}", (err, stdout, stderr) -> | |||
if err? then throw err | |||
|
|||
# Copy src content into bin | |||
exec "cp -R #{escapeShell src} #{escapeShell bin}", (err, stdout, stderr) -> | |||
if err? then throw err | |||
|
|||
# Compile coffee files | |||
for filename in findit.sync bin | |||
if filename.substring(filename.length-7) is '.coffee' | |||
# Get script from coffee file | |||
script = fs.readFileSync filename, 'utf8' | |||
# Compile into js code | |||
js = coffee.compile script | |||
# Write js file with compiled code | |||
file = fs.openSync filename.substring(0, filename.length-7)+'.js', 'w+' | |||
fs.writeSync file, js | |||
fs.closeSync file | |||
# Delete coffee file | |||
fs.unlinkSync filename | |||
|
|||
# Ensure redis-dump is executable | |||
exec "chmod +x #{escapeShell bin+'/cli/redis-dump'}", (err, stdout, stderr) -> | |||
if err? then throw err | |||
|
|||
# Finish | |||
console.log 'built redis-dump.' | |||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
#!/usr/bin/env node | |||
|
|||
require('../cli'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
(function() { | |||
|
|||
module.exports = require('./dump'); | |||
|
|||
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
(function() { | |||
var dump; | |||
|
|||
dump = require('./dump'); | |||
|
|||
dump({ | |||
filter: '*' | |||
}, function(err, result) { | |||
if (err != null) return process.stderr.write("" + err + "\n"); | |||
return console.log(result); | |||
}); | |||
|
|||
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
{ | |||
"name": "redis-dump", | |||
"version": "0.1.0", | |||
"description": "Redis dump library", | |||
"author": "Jeremy Faivre <contact@jeremyfa.com>", | |||
"main": "./bin/index.js", | |||
"scripts": { | |||
"test": "node ./bin/test.js" | |||
}, | |||
"bin": { | |||
"redis-dump": "./bin/cli/redis-dump" | |||
}, | |||
"dependencies": { | |||
"async": ">=0.1.15", | |||
"optimist": ">=0.3.1" | |||
}, | |||
"devDependencies": { | |||
"coffee-script": ">=1.2.0" | |||
}, | |||
"repository": { | |||
"type": "git", | |||
"url": "git://github.com/jeremyfa/redis-dump.git" | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,38 @@ | |||
|
|||
fs = require 'fs' | |||
path = require 'path' | |||
argv = require('optimist').argv | |||
dump = require './dump' | |||
package = JSON.parse fs.readFileSync path.normalize(__dirname+'/../package.json'), 'utf8' | |||
|
|||
if argv.help | |||
console.log """ | |||
#{package.name} #{package.version} | |||
Usage: #{package.name} [OPTIONS] | |||
-h <hostname> Server hostname (default: 127.0.0.1) | |||
-p <port> Server port (default: 6379) | |||
-f <filter> Query filter (default: *) | |||
--help Output this help and exit | |||
Examples: | |||
redis-dump | |||
redis-dump -p 6500 | |||
redis-dump -f 'mydb:*' > mydb.dump.txt | |||
The output is a valid list of redis commands. | |||
That means the following will work: | |||
redis-dump > dump.txt # Dump redis database | |||
cat dump.txt | redis-cli # Import redis database from generated file | |||
""" | |||
else | |||
params = | |||
filter: argv.f ? '*' | |||
port: argv.p ? 6379 | |||
host: argv.h ? '127.0.0.1' | |||
|
|||
dump params, (err, result) -> | |||
if err? then return process.stderr.write "#{err}\n" | |||
if result? and "#{result}".replace(/^\s+/, '').replace(/\s+$/, '') isnt '' | |||
console.log result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
#!/usr/bin/env node | |||
|
|||
require('../cli'); |
Oops, something went wrong.