Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

whoosh

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whoosh - npm Package Compare versions

Comparing version 0.3.4 to 0.3.5

6

index.js

@@ -74,2 +74,8 @@ var Client = require('ssh2').Client

},
exists: function(remotePath, next) {
sftp.stat(remotePath, function(err, stat) {
if (err && err.message !== 'No such file') return next(err)
return next(null, !!stat)
})
},
disconnect: function(next) {

@@ -76,0 +82,0 @@ if (!sftp.isConnected()) return next()

2

package.json
{
"name": "whoosh",
"version": "0.3.4",
"version": "0.3.5",
"description": "A streaming sftp client",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -78,2 +78,15 @@ # Whoosh

#### 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)
console.log(exists ? 'File exists' : 'File does not exist')
)}
})
})
#### Everything else

@@ -80,0 +93,0 @@

@@ -203,2 +203,41 @@ var assert = require('assert')

it('should report if a file exists', function(done) {
var title = this.test.title
Whoosh.connect(config, function(err, whoosh) {
assert.ifError(err)
whoosh.putContent('test message', getRemotePath(title), function(err, stats) {
assert.ifError(err)
whoosh.exists(getRemotePath(title), function(err, exists) {
assert.ifError(err)
assert.equal(exists, true)
whoosh.disconnect(done)
})
})
})
})
it('should report if a file does not exist', function(done) {
var title = this.test.title
Whoosh.connect(config, function(err, whoosh) {
assert.ifError(err)
whoosh.exists(getRemotePath(title), function(err, exists) {
assert.ifError(err)
assert.equal(exists, false)
whoosh.disconnect(done)
})
})
})
it('should not disconnect after checking if a non existent file exists', function(done) {
var title = this.test.title
Whoosh.connect(config, function(err, whoosh) {
assert.ifError(err)
whoosh.exists(getRemotePath(title), function(err, exists) {
assert.ifError(err)
assert.ok(whoosh.isConnected())
whoosh.disconnect(done)
})
})
})
function getRemotePath(filename) {

@@ -205,0 +244,0 @@ return 'files/uploads/' + (filename ? filename.replace(/\W/g, '_') : '')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc