ssh2-promise
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -97,5 +97,5 @@ "use strict"; | ||
stream.on('close', function () { | ||
console.log(`Closed stream - ${cmd}`); | ||
//console.log(`Closed stream - ${cmd}`); | ||
}).on('finish', function () { | ||
console.log(`Closed stream - ${cmd}`); | ||
//console.log(`Closed stream - ${cmd}`); | ||
}); | ||
@@ -102,0 +102,0 @@ stream.kill = function () { |
declare const _default: { | ||
/** | ||
* Peek the array | ||
*/ | ||
peek: (arr: any[]) => any; | ||
/** | ||
* End pty socket session by sending kill signal | ||
* @param {*} socket | ||
*/ | ||
endSocket: (socket: any) => void; | ||
/** | ||
* Prompt for asking anything | ||
*/ | ||
prompt: (question: string, cb: Function) => void; | ||
/** | ||
* Create a Deferred promise | ||
*/ | ||
createDeferredPromise: () => { | ||
@@ -6,0 +19,0 @@ promise: Promise<{}>; |
{ | ||
"name": "ssh2-promise", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Promise wrapper around SSH2 library", | ||
@@ -43,3 +43,3 @@ "main": "dist/index.js", | ||
"@heroku/socksv5": "^0.0.9", | ||
"ssh2": "^0.8.4" | ||
"ssh2": "^0.8.6" | ||
}, | ||
@@ -50,2 +50,3 @@ "devDependencies": { | ||
"@types/jasmine": "^2.8.9", | ||
"@types/ssh2-streams": "0.1.6", | ||
"gulp": "^3.9.1", | ||
@@ -57,3 +58,10 @@ "gulp-typescript": "^3.2.3", | ||
"typescript": "^2.6.2" | ||
}, | ||
"resolutions": { | ||
"mixin-deep": "^1.3.2", | ||
"set-value": "^2.0.1", | ||
"lodash": "^4.17.13", | ||
"lodash.template": "^4.5.0", | ||
"lodash.merge": "^4.6.2" | ||
} | ||
} |
@@ -15,2 +15,14 @@ # Description | ||
# Local Testing | ||
#### Prerequisite to be installed | ||
- docker | ||
- docker-compose | ||
```bash | ||
cd pretest | ||
docker-compose up -d | ||
cd .. | ||
yarn test | ||
``` | ||
# Usage | ||
@@ -17,0 +29,0 @@ All examples are shown in promisify and async-await manner. |
@@ -12,3 +12,3 @@ var SSHTunnel = require("../dist/index"); | ||
var fs = require("fs"); | ||
var sshConfigs = JSON.parse(fs.readFileSync("./spec/fixture.json")); | ||
var sshConfigs = require('./fixture')//JSON.parse(fs.readFileSync("./spec/fixture.json")); | ||
var util = require('util'); | ||
@@ -266,4 +266,3 @@ | ||
}) | ||
}); | ||
}); | ||
}); |
@@ -12,3 +12,3 @@ import SSHTunnel = require('../dist/index') | ||
var fs = require("fs"); | ||
var sshConfigs = JSON.parse(fs.readFileSync("./spec/fixture.json")); | ||
var sshConfigs = require('./fixture')//JSON.parse(fs.readFileSync("./spec/fixture.json")); | ||
var util = require('util'); | ||
@@ -15,0 +15,0 @@ |
@@ -9,3 +9,3 @@ var SSHTunnel = require("../dist/index"); | ||
var fs = require("fs"); | ||
var sshConfigs = JSON.parse(fs.readFileSync("./spec/fixture.json")); | ||
var sshConfigs = require('./fixture')//JSON.parse(fs.readFileSync("./spec/fixture.json")); | ||
@@ -20,3 +20,3 @@ describe("exec n spawn cmd", function () { | ||
sshTunnel.exec("whoami").then((username) => { | ||
expect(username.trim()).toEqual("ubuntu"); | ||
expect(username.trim()).toEqual("sanket"); | ||
}, (error) => { | ||
@@ -23,0 +23,0 @@ expect(error).toBeUndefined(); |
var SSHTunnel = require("../dist/index"); | ||
var fs = require('fs') | ||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000; | ||
@@ -9,3 +10,3 @@ Promise.prototype.finally = function (cb) { | ||
var fs = require("fs"); | ||
var sshConfigs = JSON.parse(fs.readFileSync("./spec/fixture.json")); | ||
var sshConfigs = require('./fixture') //var sshConfigs = JSON.parse(fs.readFileSync("./spec/fixture.json")); | ||
@@ -24,4 +25,4 @@ | ||
try{ | ||
await sftp.mkdir('/home/ubuntu/dummy') | ||
await sftp.rmdir('/home/ubuntu/dummy'); | ||
await sftp.mkdir('/home/sanket/dummy') | ||
await sftp.rmdir('/home/sanket/dummy'); | ||
expect(1).toBe(1); | ||
@@ -39,5 +40,5 @@ }catch(err){ | ||
try{ | ||
await sshTunnel.exec("rm", ["-rf", "/home/ubuntu/dummy"]) | ||
await sftp.writeFile('/home/ubuntu/dummy', "testing123"); | ||
var content = await sftp.readFile('/home/ubuntu/dummy', "utf8"); | ||
await sshTunnel.exec("rm", ["-rf", "/home/sanket/dummy"]) | ||
await sftp.writeFile('/home/sanket/dummy', "testing123"); | ||
var content = await sftp.readFile('/home/sanket/dummy', "utf8"); | ||
expect(content).toBe("testing123"); | ||
@@ -47,3 +48,3 @@ }catch(err){ | ||
}finally{ | ||
sshTunnel.exec("rm", ["-rf", "/home/ubuntu/dummy"]) | ||
sshTunnel.exec("rm", ["-rf", "/home/sanket/dummy"]) | ||
done(); | ||
@@ -57,6 +58,7 @@ } | ||
try{ | ||
await sftp.fastPut('C:\\test\\test1\\test2.log', "/home/ubuntu/test2.txt"); | ||
fs.writeFileSync('./test.txt', "Test module"); | ||
await sftp.fastPut('./test.txt', "/home/sanket/test2.txt"); | ||
expect(1).toBe(1); | ||
//var content = await sftp.readFile('/dummy', "utf8"); | ||
//expect(content).toBeNonEmptyString(); | ||
var content = await sftp.readFile('/home/sanket/test2.txt', "utf8"); | ||
expect(content).toBe("Test module"); | ||
}catch(err){ | ||
@@ -66,2 +68,3 @@ console.log(err); | ||
}finally{ | ||
fs.unlinkSync('./test.txt') | ||
done(); | ||
@@ -84,3 +87,3 @@ } | ||
it("write stream", function (done) { | ||
sftp.createWriteStream("/home/ubuntu/abc").then((stream) => { | ||
sftp.createWriteStream("/home/sanket/abc").then((stream) => { | ||
expect(stream).toBeDefined(); | ||
@@ -100,3 +103,3 @@ stream.write('dummy\n\n\nasdfjsdaf\n', () => { | ||
it("read stream", function (done) { | ||
sftp.createReadStream("/home/ubuntu/abc").then((stream) => { | ||
sftp.createReadStream("/home/sanket/abc").then((stream) => { | ||
expect(stream).toBeDefined(); | ||
@@ -122,3 +125,3 @@ var buffer = ""; | ||
it("get stats", function (done) { | ||
sftp.getStat("/home/ubuntu/abc", "r").then((stat) => { | ||
sftp.getStat("/home/sanket/abc", "r").then((stat) => { | ||
expect(stat).toBeDefined(); | ||
@@ -134,3 +137,3 @@ done(); | ||
it("set stats", function (done) { | ||
sftp.setStat("/home/ubuntu/abc", { mode: 0755 }).then(() => { | ||
sftp.setStat("/home/sanket/abc", { mode: 0755 }).then(() => { | ||
expect(1).toBe(1); | ||
@@ -145,3 +148,3 @@ }, (err) => { | ||
it("update time & access time", function (done) { | ||
sftp.changeTimestamp("/home/ubuntu/abc", new Date().getTime(), new Date().getTime()).then(() => { | ||
sftp.changeTimestamp("/home/sanket/abc", new Date().getTime(), new Date().getTime()).then(() => { | ||
expect(1).toBe(1); | ||
@@ -156,3 +159,3 @@ }, (err) => { | ||
it("unable to chown to root", function (done) { | ||
sftp.changeOwner("/home/ubuntu/abc", 0, 0).then((handle) => { | ||
sftp.changeOwner("/home/sanket/abc", 0, 0).then((handle) => { | ||
expect('1').toBe('2'); | ||
@@ -168,3 +171,3 @@ }, (err) => { | ||
/* it("rename file", function (done) { | ||
sftp.createWriteStream("/home/ubuntu/abc").then((stream) => { | ||
sftp.createWriteStream("/home/sanket/abc").then((stream) => { | ||
expect(stream).toBeDefined(); | ||
@@ -174,3 +177,3 @@ stream.write('dummy\n\n\nasdfjsdaf\n', () => { | ||
expect('1').toBe('1'); | ||
sftp.rename("/home/ubuntu/abc", "/home/ubuntu/newabc").then(() => { | ||
sftp.rename("/home/sanket/abc", "/home/sanket/newabc").then(() => { | ||
expect('1').toBe('1') | ||
@@ -193,3 +196,3 @@ }).catch((err) => { | ||
it("move file to different location", function (done) { | ||
sftp.changeOwner("/home/ubuntu/abc", 0, 0).then((handle) => { | ||
sftp.changeOwner("/home/sanket/abc", 0, 0).then((handle) => { | ||
expect('1').toBe('2'); | ||
@@ -196,0 +199,0 @@ }, (err) => { |
@@ -123,5 +123,5 @@ import { EventEmitter } from 'events'; | ||
stream.on('close', function () { | ||
console.log(`Closed stream - ${cmd}`); | ||
//console.log(`Closed stream - ${cmd}`); | ||
}).on('finish', function () { | ||
console.log(`Closed stream - ${cmd}`); | ||
//console.log(`Closed stream - ${cmd}`); | ||
}); | ||
@@ -128,0 +128,0 @@ stream.kill = function () { |
@@ -6,2 +6,3 @@ { | ||
"src/BaseSFTP.ts", | ||
"src/BaseSSH2Promise.ts", | ||
"src/sshConnection.ts", | ||
@@ -8,0 +9,0 @@ "src/sshConstants.ts", |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
225272
42
3450
590
10
5
Updatedssh2@^0.8.6