expect-telnet
Advanced tools
Comparing version
14
index.js
@@ -10,3 +10,3 @@ "use strict"; | ||
module.exports = function (dest, seq, opts, cb) { | ||
module.exports = function(dest, seq, opts, cb) { | ||
var socket = new net.Socket(), interacting, saved = ""; | ||
@@ -22,3 +22,3 @@ if (typeof opts === "function") cb = opts; | ||
socket.on("error", function (err) { | ||
socket.on("error", function(err) { | ||
if (interacting) interacting = false; | ||
@@ -28,3 +28,3 @@ endSocket(socket); | ||
}); | ||
socket.on("end", function () { | ||
socket.on("end", function() { | ||
if (interacting) { | ||
@@ -39,3 +39,3 @@ process.stdin.removeAllListeners("data"); | ||
var i; | ||
seq.some(function (entry, index) { | ||
seq.some(function(entry, index) { | ||
i = entry.done ? undefined : index; | ||
@@ -51,3 +51,3 @@ return !entry.done; | ||
if (!seq[i].timeout) { | ||
seq[i].timeout = setTimeout(function () { | ||
seq[i].timeout = setTimeout(function() { | ||
endSocket(socket); | ||
@@ -76,3 +76,3 @@ cb(new Error("Expect sequence timeout: " + seq[i].expect)); | ||
var lines = []; | ||
saved.split(/\r?\n/).forEach(function (line) { | ||
saved.split(/\r?\n/).forEach(function(line) { | ||
if (line) lines.push(line); | ||
@@ -91,3 +91,3 @@ }); | ||
interacting = true; | ||
process.stdin.on("data", function (c) { | ||
process.stdin.on("data", function(c) { | ||
if (!socket.writable) return; | ||
@@ -94,0 +94,0 @@ if (c.toString("hex") === "7f") c = Buffer("08", "hex"); // Convert DEL to BKSP |
{ | ||
"name": "expect-telnet", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "telnet automation through expect-send sequences, like in Tcl", | ||
@@ -5,0 +5,0 @@ "author": "silverwind <me@silverwind.io> (https://github.com/silverwind)", |
6388
-0.11%