expect-telnet
Advanced tools
Comparing version
13
index.js
@@ -54,3 +54,14 @@ "use strict"; | ||
saved += chunk; | ||
if (saved.indexOf(seq[i].expect) !== -1) { | ||
var matched; | ||
if (seq[i].expect instanceof RegExp) { | ||
matched = seq[i].expect.test(saved); | ||
} else if (typeof seq[i].expect === "string") { | ||
matched = saved.indexOf(seq[i].expect) !== -1; | ||
} else { | ||
endSocket(socket); | ||
cb(new Error("Expected a String or RegExp:" + seq[i].expect)); | ||
} | ||
if (matched) { | ||
clearTimeout(seq[i].timeout); | ||
@@ -57,0 +68,0 @@ seq[i].done = true; |
{ | ||
"name": "expect-telnet", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "telnet automation through expect-send sequences, like in Tcl", | ||
@@ -5,0 +5,0 @@ "author": "silverwind <me@silverwind.io> (https://github.com/silverwind)", |
@@ -45,3 +45,3 @@ # expect-telnet [](https://www.npmjs.org/package/expect-telnet) [](https://david-dm.org/silverwind/expect-telnet) | ||
#### Expect step object | ||
- `expect` *string* : String to expect. | ||
- `expect` *string* / *regexp* : String or RegExp to expect. | ||
- `send` *string* : String to send when `expect` is found. | ||
@@ -48,0 +48,0 @@ - `out` *function*: Output function, receives the output since the previous step. |
6401
5.18%81
12.5%