Skip to content

Commit 9bd6cef

Browse files
committed
Update documentation and prepare for release 0.1.1
1 parent 3a4e6f7 commit 9bd6cef

2 files changed

Lines changed: 42 additions & 31 deletions

File tree

README.md

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ host = {
8282
//stream object used to respond to the timeout without having to close the connection
8383
//connection object gives access to close the shell using connection.end()
8484
},
85+
onError: function ( err, type, close ) {
86+
//optional code for responding to error
87+
},
88+
onClose: function ( has_error, command ) {
89+
//optional code for responding to close
90+
// has_error: boolean. True if error hapen
91+
// command: latest command that was processing when connection get closed.
92+
},
8593
onEnd: function( notices, sshObj ) {
8694
//optional code to run at the end of the session
8795
//notices is array of all notices for each command.
@@ -147,34 +155,39 @@ dotenv.load();
147155
var Email = require('email');
148156

149157
var host = {
150-
server: {
151-
host: process.env.HOST,
152-
port: process.env.PORT,
153-
userName: process.env.USER_NAME,
154-
password: process.env.PASSWORD,
155-
passPhrase: process.env.PASS_PHRASE,
156-
privateKey: require('fs').readFileSync(process.env.PRIV_KEY_PATH)
157-
},
158-
commands: [
159-
"echo $(pwd)",
160-
"cd ~/",
161-
"ls -l",
162-
"echo $(pwd)",
163-
"ls -l",
164-
],
165-
onCommandComplete: function( notice, sshObj ) {
166-
//confirm it is the root home dir and change to root's .ssh folder
167-
if (notice.command === "echo $(pwd)" && notice.output.indexOf("/root") != -1 ) {
168-
sshObj.commands.push("cd .ssh");
169-
}
170-
//we are listing the dir so output it to the msg handler
171-
else if (notice.command === "ls -l"){
172-
console.log(notice.output);
158+
server: {
159+
host: process.env.HOST,
160+
port: process.env.PORT,
161+
userName: process.env.USER_NAME,
162+
password: process.env.PASSWORD,
163+
passPhrase: process.env.PASS_PHRASE,
164+
privateKey: require('fs').readFileSync(process.env.PRIV_KEY_PATH)
165+
},
166+
commands: [
167+
"echo $(pwd)",
168+
"cd ~/",
169+
"ls -l",
170+
"echo $(pwd)",
171+
"ls -l",
172+
],
173+
onCommandComplete: function( notice, sshObj ) {
174+
//confirm it is the root home dir and change to root's .ssh folder
175+
if (notice.command === "echo $(pwd)" && notice.output.indexOf("/root") != -1 ) {
176+
sshObj.commands.push("cd .ssh");
177+
}
178+
//we are listing the dir so output it to the msg handler
179+
else if (notice.command === "ls -l"){
180+
console.log(notice.output);
181+
}
182+
},
183+
onClose: function( has_error, command ) {
184+
//has_error is true if session has bin interrupted.
185+
//command is latest command that was processing and did not finish.
186+
console.log(command);
187+
},
188+
onEnd: function( notices, sshObj ) {
189+
console.log(notices);
173190
}
174-
},
175-
onEnd: function( notices, sshObj ) {
176-
console.log(notices);
177-
}
178191
};
179192

180193
//Create a new instance

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenci-shell",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"author": "Gormartsen",
55
"description": "A wrapper class for node.js ssh2 to run multiple commands.",
66
"main": "./zenci-shell.js",
@@ -19,8 +19,6 @@
1919
"server",
2020
"multiple",
2121
"commands",
22-
"tunnel",
23-
"tunnelling",
2422
"deploy",
2523
"automation"
2624
],
@@ -36,4 +34,4 @@
3634
"test": "test"
3735
},
3836
"license": "MIT"
39-
}
37+
}

0 commit comments

Comments
 (0)