commit 34f9b5e611e7f36caf44a6c5db23c707d716e999
parent fb7c83d1ca9baa8c6736fdb34dab445de5d288b3
Author: William Casarin <jb55@jb55.com>
Date: Tue, 18 Jul 2017 09:38:21 -0700
more reliable ready check
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/index.js b/index.js
@@ -20,7 +20,7 @@ if (!user || !pass || !cmd) {
usage();
}
-var hadFirst = false;
+var ready = false;
const socket = tls.connect({host: host, port: port, rejectUnauthorized: !allow}, () => {
function handleNotifications() {
@@ -30,11 +30,12 @@ const socket = tls.connect({host: host, port: port, rejectUnauthorized: !allow},
const res = /\* (\d+) EXISTS/.exec(str);
- if (hadFirst && res && res[1]) {
+ if (ready && res && res[1]) {
execFile(cmd, [res[1]])
}
- if (!hadFirst) hadFirst = true;
+ if (/\+ idling/.test(str))
+ ready = true;
})
}