Comparing version 0.3.7 to 1.1.0
@@ -105,4 +105,3 @@ var Client = require('ssh2').Client | ||
debug('Connection to %s:%s ended', config.hostname, config.port) | ||
disconnected = true | ||
disconnecting = false | ||
disconnect() | ||
}) | ||
@@ -112,5 +111,9 @@ | ||
debug('Connection to %s:%s closed', config.hostname, config.port) | ||
disconnect() | ||
}) | ||
function disconnect() { | ||
disconnected = true | ||
disconnecting = false | ||
}) | ||
} | ||
} | ||
@@ -117,0 +120,0 @@ } |
{ | ||
"name": "whoosh", | ||
"version": "0.3.7", | ||
"version": "1.1.0", | ||
"description": "A streaming sftp client", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "NODE_ENV=test mocha --recursive tests", | ||
"lint": "node_modules/.bin/eslint .", | ||
"test": "mocha", | ||
"lint": "eslint .", | ||
"istanbul": "istanbul cover --report html --report lcov _mocha", | ||
"codeclimate": "codeclimate-test-reporter < coverage/lcov.info", | ||
"precommit": "npm run lint", | ||
"prepush": "npm test" | ||
"prepush": "npm test", | ||
"docker": "docker-compose up -d" | ||
}, | ||
@@ -20,13 +23,16 @@ "keywords": [ | ||
"devDependencies": { | ||
"async": "^1.2.1", | ||
"eslint": "^0.23.0", | ||
"eslint-config-imperative": "0.0.6", | ||
"fs-extra": "^0.18.4", | ||
"husky": "^0.8.1", | ||
"mocha": "^2.2.5" | ||
"async": "^2.1.4", | ||
"chai": "^3.5.0", | ||
"codeclimate-test-reporter": "^0.4.0", | ||
"eslint": "^3.12.2", | ||
"eslint-config-imperative": "^1.0.0", | ||
"eslint-plugin-imperative": "^1.0.0", | ||
"fs-extra": "^2.0.0", | ||
"husky": "^0.13.1", | ||
"mocha": "^3.2.0" | ||
}, | ||
"dependencies": { | ||
"debug": "^2.2.0", | ||
"lodash": "^3.9.3", | ||
"ssh2": "^0.4.8" | ||
"debug": "^2.6.0", | ||
"lodash": "^4.17.4", | ||
"ssh2": "^0.5.4" | ||
}, | ||
@@ -43,3 +49,3 @@ "directories": { | ||
}, | ||
"homepage": "https://github.com/guidesmiths/whoosh" | ||
"homepage": "https://guidesmiths.github.io/whoosh/" | ||
} |
114
README.md
# Whoosh | ||
Whoosh is an ultra thin wrapper for [SFTPStream](https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md), with the additional benefit of being able to easily stream in memory content to/from an SFTP server. | ||
Whoosh is an ultra thin wrapper for [SFTPStream](https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md). It's so thin that there's not much point using it unless you want to stream in memory content to/from an SFTP server. | ||
[![NPM version](https://img.shields.io/npm/v/whoosh.svg?style=flat-square)](https://www.npmjs.com/package/whoosh) | ||
[![NPM downloads](https://img.shields.io/npm/dm/whoosh.svg?style=flat-square)](https://www.npmjs.com/package/whoosh) | ||
[![Build Status](https://img.shields.io/travis/guidesmiths/whoosh/master.svg)](https://travis-ci.org/guidesmiths/whoosh) | ||
[![Code Climate](https://codeclimate.com/github/guidesmiths/whoosh/badges/gpa.svg)](https://codeclimate.com/github/guidesmiths/whoosh) | ||
[![Test Coverage](https://codeclimate.com/github/guidesmiths/whoosh/badges/coverage.svg)](https://codeclimate.com/github/guidesmiths/whoosh/coverage) | ||
[![Code Style](https://img.shields.io/badge/code%20style-imperative-brightgreen.svg)](https://github.com/guidesmiths/eslint-config-imperative) | ||
[![Dependency Status](https://david-dm.org/guidesmiths/whoosh.svg)](https://david-dm.org/guidesmiths/whoosh) | ||
[![devDependencies Status](https://david-dm.org/guidesmiths/whoosh/dev-status.svg)](https://david-dm.org/guidesmiths/whoosh?type=dev) | ||
## Usage | ||
## API | ||
### Connecting | ||
### connect(<params;>, <cb>) | ||
Connect to an sftp server | ||
```js | ||
@@ -14,4 +23,4 @@ Whoosh.connect({ | ||
password: 'secret' | ||
}, function(err, whoosh) { | ||
// Do stuff with whoosh | ||
}, (err, client) => { | ||
// profit :) | ||
}) | ||
@@ -21,38 +30,41 @@ ``` | ||
### What can I do with whoosh? | ||
### disconnect(<cb>) | ||
Disconnect from an sftp server | ||
``` | ||
Whoosh.connect(config, (err, client) => { | ||
client.disconnect(() => { | ||
// Disconnected | ||
}) | ||
}) | ||
``` | ||
#### isConnected (sync) | ||
### isConnected() | ||
Returns true when connected to the SFTP server. Useful for checking whether a previously established connection has dropped. | ||
```js | ||
Whoosh.connect(config, function(err, whoosh) { | ||
if (err) return bail(err) | ||
assert.ok(whoosh.isConnected()) | ||
whoosh.disconnect(function() { | ||
assert.ok(!whoosh.isConnected()) | ||
)} | ||
Whoosh.connect(config, (err, client) => { | ||
if (err) throw err | ||
client.isConnected() // returns true | ||
}) | ||
``` | ||
#### isConnected (async) | ||
### isConnected(<cb>) | ||
Asynchronous version of isConnected | ||
```js | ||
Whoosh.connect(config, function(err, whoosh) { | ||
if (err) return bail(err) | ||
whoosh.isConnected(function(err, connected) { | ||
assert.ok(connected) | ||
whoosh.disconnect(function() { | ||
whoosh.isConnected(function(err, connected) { | ||
assert.ok(!connected) | ||
}) | ||
}) | ||
Whoosh.connect(config, (err, client) => { | ||
if (err) throw err | ||
client.isConnected((err, connected) => { | ||
// Check connected status here | ||
)} | ||
}) | ||
``` | ||
#### getContent | ||
### getContent(<path>, [<options>], <cb>) | ||
Streams the contents of a remote file to a variable | ||
```js | ||
Whoosh.connect(config, function(err, whoosh) { | ||
if (err) return bail(err) | ||
whoosh.getContent('some/remote/file', options, function(err, content, stats) { | ||
whoosh.disconnect(function() { | ||
if (err) return bail(err) | ||
console.log('Downloaded ' + stats.bytes + ' bytes in ' + stats.duration + 'ms') | ||
Whoosh.connect(config, (err, client) => { | ||
if (err) throw err | ||
client.getContent('some/remote/file', (err, content, stats) => { | ||
client.disconnect(() => { | ||
if (err) throw err | ||
console.log(`Downloaded ${stats.bytes} bytes in ${stats.duration} ms`) | ||
)} | ||
@@ -64,12 +76,11 @@ }) | ||
#### putContent | ||
### putContent(<content;>, <path>, [<options>], <cb>) | ||
Streams the contents of a variable to a remote file | ||
```js | ||
var content = 'my content' | ||
Whoosh.connect(config, function(err, whoosh) { | ||
if (err) return bail(err) | ||
whoosh.putContent('some/remote/file', content, options, function(err, stats) { | ||
whoosh.disconnect(function() { | ||
if (err) return bail(err) | ||
console.log('Uploaded ' + stats.bytes + ' bytes in ' + stats.duration + 'ms') | ||
Whoosh.connect(config, (err, client) => { | ||
if (err) throw err | ||
client.putContent('some conent', 'some/remote/file', (err, stats) => { | ||
client.disconnect(() => { | ||
if (err) throw err | ||
console.log(`Uploaded ${stats.bytes} bytes in ${stats.duration} ms`) | ||
}) | ||
@@ -81,10 +92,10 @@ }) | ||
#### exists | ||
### exists | ||
Reports on whether a remote file exists | ||
```js | ||
Whoosh.connect(config, function(err, whoosh) { | ||
if (err) return bail(err) | ||
whoosh.exists('some/remote/file', function(err, exists) { | ||
whoosh.disconnect(function() { | ||
if (err) return bail(err) | ||
Whoosh.connect(config, function(err, client) { | ||
if (err) throw err | ||
client.exists('some/remote/file', (err, exists) => { | ||
client.disconnect(() => { | ||
if (err) throw err | ||
console.log(exists ? 'File exists' : 'File does not exist') | ||
@@ -95,11 +106,12 @@ )} | ||
``` | ||
#### Everything else | ||
The ```whoosh``` object is just a decorated instance of [SFTPStream](https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md) so all the other SFTP methods are available. e.g. | ||
## Everything else | ||
The ```client``` object is just a decorated instance of [SFTPStream](https://github.com/mscdex/ssh2-streams/blob/master/SFTPStream.md) so all the other SFTP methods are available. e.g. | ||
```js | ||
Whoosh.connect(config, function(err, whoosh) { | ||
if (err) return bail(err) | ||
whoosh.unlink('some/remote/file', function(err) { | ||
whoosh.disconnect(function() { | ||
if (err) return bail(err) | ||
Whoosh.connect(config, function(err, client) { | ||
if (err) throw err | ||
client.unlink('some/remote/file', function(err) { | ||
client.disconnect(() => { | ||
if (err) throw err | ||
console.log('Deleted some/remote/file') | ||
@@ -106,0 +118,0 @@ }) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
21570
16
323
0
120
9
1
+ Addedlodash@4.17.21(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedssh2@0.5.5(transitive)
+ Addedssh2-streams@0.1.20(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@0.0.1(transitive)
- Removedlodash@3.10.1(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedssh2@0.4.15(transitive)
- Removedssh2-streams@0.0.23(transitive)
- Removedstring_decoder@0.10.31(transitive)
Updateddebug@^2.6.0
Updatedlodash@^4.17.4
Updatedssh2@^0.5.4