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

neo-scp

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neo-scp - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

.eslintignore

55

lib/NeoScp.js

@@ -11,3 +11,3 @@ const fs = require('fs');

class NeoScp extends EventEmitter {
constructor (connection) {
constructor(connection) {
super();

@@ -17,3 +17,3 @@ this.conn = connection;

debug (data) {
debug(data) {
this.emit('debug', data);

@@ -30,3 +30,3 @@ }

*/
putFile (localFile, remoteFile, callback) {
putFile(localFile, remoteFile, callback) {
let self = this;

@@ -76,2 +76,49 @@

/**
* Gets a file from host
*
* @param {string} remoteFile
* @param {string} localFile
* @param {function} callback
* @memberof NeoScp
*/
getFile(remoteFile, localFile, callback) {
let self = this;
self.conn.exec(`scp -f ${remoteFile}`, (err, stream) => {
if (err) callback(err);
let fileBuffer = Buffer.from([0]);
stream.write(Buffer.from([0]));
stream.on('close', () => {
self.debug('Stream close');
fs.writeFileSync(localFile, fileBuffer.slice(1, -1));
stream.end();
callback();
});
let jump = 0;
stream.on('data', (data) => {
stream.write(Buffer.from([0]));
if (jump === 0) {
jump = 1;
return;
}
fileBuffer = Buffer.concat([fileBuffer, data]);
self.debug(`STDOUT: "${data}"`);
});
stream.stderr.on('data', data => {
self.debug(`STDERR: "${data}"`);
});
});
}
/**
* Gets the remote file size

@@ -83,3 +130,3 @@ *

*/
getFileSize (remoteFile, callback) {
getFileSize(remoteFile, callback) {
let self = this;

@@ -86,0 +133,0 @@ self.conn.exec(`ls -la ${remoteFile} | tr -s ' '| cut -d' ' -f5`, (err, stream) => {

9

package.json
{
"name": "neo-scp",
"version": "0.1.1",
"version": "0.1.2",
"description": "A pure JS real scp module based on ssh2 module",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha"
},

@@ -24,3 +24,6 @@ "repository": {

},
"homepage": "https://github.com/Fabio286/neo-scp#readme"
"homepage": "https://github.com/Fabio286/neo-scp#readme",
"dependencies": {
"ssh2": "^0.8.4"
}
}

@@ -74,3 +74,4 @@ # Neo SCP

Coming soon.
Gets a file from remote host.
You must pass the `remoteFile` path, the `localFile` destination path and a callback function.

@@ -77,0 +78,0 @@ ## Debug

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