Comparing version 2.0.2 to 2.0.3
@@ -94,5 +94,7 @@ 'use strict'; | ||
var stderr = _ref.stderr; | ||
var code = _ref.code; | ||
var signal = _ref.signal; | ||
if (options.stream === 'both') { | ||
return { stderr: stderr, stdout: stdout }; | ||
return { stderr: stderr, stdout: stdout, code: code, signal: signal }; | ||
} else if (options.stream === 'stderr') { | ||
@@ -110,2 +112,4 @@ return stderr; | ||
value: function execCommand(command) { | ||
var _this2 = this; | ||
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
@@ -128,7 +132,10 @@ | ||
} | ||
return this.execStream(command).then(function (stream) { | ||
return new Promise(function (resolve) { | ||
return new Promise(function (resolve, reject) { | ||
_this2.connection.exec(command, function (err, stream) { | ||
if (err) { | ||
return reject(err); | ||
} | ||
var contents = { stdout: [], stderr: [] }; | ||
stream.on('close', function () { | ||
resolve({ stdout: contents.stdout.join(''), stderr: contents.stderr.join('') }); | ||
stream.on('close', function (code, signal) { | ||
resolve({ stdout: contents.stdout.join(''), stderr: contents.stderr.join(''), code: code, signal: signal }); | ||
}).on('data', function (data) { | ||
@@ -146,21 +153,3 @@ contents.stdout.push(data); | ||
} | ||
// Private method. Not for public use | ||
}, { | ||
key: 'execStream', | ||
value: function execStream(command) { | ||
var _this2 = this; | ||
if (!this.connected) { | ||
throw new Error('SSH Not yet connected'); | ||
} | ||
return new Promise(function (resolve, reject) { | ||
_this2.connection.exec(command, function (error, stream) { | ||
if (error) { | ||
reject(error); | ||
} else resolve(stream); | ||
}); | ||
}); | ||
} | ||
}, { | ||
key: 'put', | ||
@@ -167,0 +156,0 @@ value: function put(localFile, remoteFile, SFTP) { |
{ | ||
"name": "node-ssh", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "SS2 with Promises", | ||
@@ -5,0 +5,0 @@ "main": "Dist/SSH.js", |
@@ -70,5 +70,5 @@ // @Compiler-Transpile "true" | ||
options.stream = validStreams.has(options.stream) ? options.stream : 'stdout' | ||
return this.execCommand([filePath].concat(args).join(' '), options).then(({stdout, stderr}) => { | ||
return this.execCommand([filePath].concat(args).join(' '), options).then(({stdout, stderr, code, signal}) => { | ||
if (options.stream === 'both') { | ||
return {stderr, stdout} | ||
return {stderr, stdout, code, signal} | ||
} else if (options.stream === 'stderr') { | ||
@@ -99,7 +99,10 @@ return stderr | ||
} | ||
return this.execStream(command).then(function(stream) { | ||
return new Promise(function(resolve) { | ||
return new Promise((resolve, reject) => { | ||
this.connection.exec(command, function(err, stream) { | ||
if (err) { | ||
return reject(err) | ||
} | ||
const contents = {stdout: [], stderr: []} | ||
stream.on('close', function() { | ||
resolve({stdout: contents.stdout.join(''), stderr: contents.stderr.join('')}) | ||
stream.on('close', function(code, signal) { | ||
resolve({stdout: contents.stdout.join(''), stderr: contents.stderr.join(''), code, signal}) | ||
}).on('data', function(data) { | ||
@@ -117,15 +120,2 @@ contents.stdout.push(data) | ||
} | ||
// Private method. Not for public use | ||
execStream(command) { | ||
if (!this.connected) { | ||
throw new Error('SSH Not yet connected') | ||
} | ||
return new Promise((resolve, reject) => { | ||
this.connection.exec(command, function(error, stream) { | ||
if (error) { | ||
reject(error) | ||
} else resolve(stream) | ||
}) | ||
}) | ||
} | ||
put(localFile, remoteFile, SFTP, retry = true) { | ||
@@ -132,0 +122,0 @@ if (!this.connected) { |
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
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
18635
448