Comparing version 0.1.1 to 0.2.0
18
index.js
@@ -43,11 +43,2 @@ var Client = require('ssh2').Client | ||
}, | ||
getContentAndDisconnect: function(remotePath, options, next) { | ||
if (arguments.length === 2) return sftp.getContentAndDisconnect(remotePath, {}, arguments[1]) | ||
sftp.getContent(remotePath, options, function(err, content) { | ||
sftp.disconnect(function() { | ||
next(err, content) | ||
}) | ||
}) | ||
}, | ||
putContent: function(content, remotePath, options, next) { | ||
@@ -70,11 +61,2 @@ if (arguments.length === 3) return sftp.putContent(content, remotePath, {}, arguments[2]) | ||
}, | ||
putContentAndDisconnect: function(content, remotePath, options, next) { | ||
if (arguments.length === 3) return sftp.putContentAndDisconnect(content, remotePath, {}, arguments[2]) | ||
sftp.putContent(content, remotePath, options, function(err, stats) { | ||
sftp.disconnect(function() { | ||
next(err, stats) | ||
}) | ||
}) | ||
}, | ||
disconnect: function(next) { | ||
@@ -81,0 +63,0 @@ if (connection._sock.destroyed) return next() |
{ | ||
"name": "whoosh", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "A streaming sftp client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -28,3 +28,3 @@ # Whoosh | ||
if (err) return bail(err) | ||
console.log('Uploaded ' + stats.size + ' bytes') | ||
console.log('Uploaded ' + stats.size + ' bytes') | ||
}) | ||
@@ -42,3 +42,3 @@ }) | ||
if (err) return bail(err) | ||
console.log('Downloaded ' + Buffer.byteLength(content.length) + ' bytes') | ||
console.log('Downloaded ' + Buffer.byteLength(content.length) + ' bytes') | ||
)} | ||
@@ -51,5 +51,2 @@ }) | ||
### Automatic disconnect | ||
It can be annoying to explicitly disconnect after each call, so we've added ```putContentAndDisconnect``` and ```getContentAndDisconnect``` variations which will disconnect before invoking the callback. | ||
### Everything else | ||
@@ -64,3 +61,3 @@ | ||
if (err) return bail(err) | ||
console.log('Deleted some/remote/file.txt') | ||
console.log('Deleted some/remote/file.txt') | ||
}) | ||
@@ -67,0 +64,0 @@ }) |
@@ -162,27 +162,2 @@ var assert = require('assert') | ||
it('should upload content and disconnect', function(done) { | ||
var title = this.test.title | ||
Whoosh.connect(config, function(err, whoosh) { | ||
assert.ifError(err) | ||
whoosh.putContentAndDisconnect('test message', getRemotePath(title), function(err, stats) { | ||
assert.ifError(err) | ||
assert.equal('test message', fs.readFileSync(getLocalPath(title)).toString()) | ||
assert.equal(stats.size, 12) | ||
whoosh.disconnect(done) | ||
}) | ||
}) | ||
}) | ||
it('should download content and disconnect', function(done) { | ||
var title = this.test.title | ||
Whoosh.connect(config, function(err, whoosh) { | ||
assert.ifError(err) | ||
fs.writeFileSync(getLocalPath(title), 'test message') | ||
whoosh.getContentAndDisconnect(getRemotePath(title), function(err, content) { | ||
assert.equal('test message', content) | ||
whoosh.disconnect(done) | ||
}) | ||
}) | ||
}) | ||
function getRemotePath(filename) { | ||
@@ -189,0 +164,0 @@ return 'files/uploads/' + (filename ? filename.replace(/\W/g, '_') : '') |
13528
220
66