From 980e65bd2c5af0cd2cf1d398f360a21557ec9245 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 11 Aug 2013 23:04:00 -0500 Subject: [PATCH] try hex char representations for terminfo subdirectory. see #2. --- lib/tput.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/tput.js b/lib/tput.js index ead7c5b..ec25651 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -163,22 +163,41 @@ Tput._tprefix = Tput.prototype._tprefix = function(prefix, term) { if (!prefix) return; + var file + , ch; + if (!term) { file = path.resolve(prefix, 'x'); try { fs.statSync(file); return prefix; } catch (e) { - return; + ; } + file = path.resolve(prefix, '78'); + try { + fs.statSync(file); + return prefix; + } catch (e) { + ; + } + return; } - var file = path.resolve( - prefix, - path.basename(term[0]), - path.basename(term) - ); + term = path.basename(term); + file = path.resolve(prefix, term[0], term); + try { + fs.statSync(file); + return file; + } catch (e) { + ; + } + + ch = term[0].charCodeAt(0).toString(16); + if (ch.length < 2) ch = '0' + ch; + + file = path.resolve(prefix, ch, term); try { fs.statSync(file); return file;