From 445e278af0089e0f8b595100f7a6afad6d8525d6 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 16 Jul 2013 15:13:17 -0500 Subject: [PATCH] check all terminfo/termcap paths/variables. --- lib/tput.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/tput.js b/lib/tput.js index a7a9a65..ccf0dc6 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -105,6 +105,12 @@ Tput.prototype.readTerminfo = function(data) { var file = this.terminfoFile || this._terminfoPrefix(this.terminfoPrefix) || this._terminfoPrefix('/usr/share/terminfo') + || this._terminfoPrefix('/usr/share/lib/terminfo') + || this._terminfoPrefix('/usr/lib/terminfo') + || this._terminfoPrefix('/usr/local/share/terminfo') + || this._terminfoPrefix('/usr/local/share/lib/terminfo') + || this._terminfoPrefix('/usr/local/lib/terminfo') + || this._terminfoPrefix('/usr/local/ncurses/lib/terminfo') || this._terminfoPrefix(process.env.HOME + '/.terminfo'); data = fs.readFileSync(file); } @@ -1082,12 +1088,19 @@ Tput.prototype._parsePadding = function(code, print, done) { */ Tput.prototype.readTermcap = function(data) { - var self = this; + var self = this + , TERMCAP = process.env.TERMCAP || '' + , TERMPATH = process.env.TERMPATH || '' + , HOME = process.env.HOME || ''; + // TODO: Check to make sure termcap data matches + // the term name, otherwise keep searching. var data = data || tryRead(this.termcapFile) - || tryRead(process.env.TERMCAP) - || process.env.TERMCAP + || (TERMCAP[0] === '/' ? tryRead(TERMCAP) : TERMCAP) + || (TERMPATH && tryRead(TERMPATH.split(/[: ]/))) + || tryRead(HOME + '/.termcap') + || tryRead('/usr/share/misc/termcap') || tryRead('/etc/termcap') || Tput.termcap; @@ -1412,6 +1425,13 @@ function write(data) { } function tryRead(file) { + if (Array.isArray(file)) { + for (var i = 0; i < file.length; i++) { + var data = tryRead(file[i]); + if (data) return data; + } + return ''; + } if (!file) return ''; file = path.resolve.apply(path, arguments); try {