From 7b3557262f44e0fce93763efa1e716a38ef15923 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 11 Aug 2013 23:13:28 -0500 Subject: [PATCH] check TERMINFO_DIRS correctly. --- lib/tput.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/tput.js b/lib/tput.js index ec25651..ec42b1a 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -143,12 +143,16 @@ Tput.prototype.readTerminfo = function(term) { Tput._prefix = Tput.prototype._prefix = function(term) { + var TERMINFO = process.env.TERMINFO || '' + , TERMINFO_DIRS = process.env.TERMINFO_DIRS || '' + , HOME = process.env.HOME || ''; + return (term && ~term.indexOf(path.sep) && term) || (term && this.terminfoFile) || this._tprefix(this.terminfoPrefix, term) - || this._tprefix(process.env.TERMINFO, term) - || this._tprefix(process.env.TERMINFO_DIRS, term) - || this._tprefix(process.env.HOME + '/.terminfo', term) + || this._tprefix(TERMINFO, term) + || this._tprefix(TERMINFO_DIRS.split(':'), term) + || this._tprefix(HOME + '/.terminfo', term) || this._tprefix('/usr/share/terminfo', term) || this._tprefix('/usr/share/lib/terminfo', term) || this._tprefix('/usr/lib/terminfo', term) @@ -164,7 +168,16 @@ Tput.prototype._tprefix = function(prefix, term) { if (!prefix) return; var file - , ch; + , ch + , i; + + if (Array.isArray(prefix)) { + for (i = 0; i < prefix.length; i++) { + file = this._tprefix(prefix[i], term); + if (file) return file; + } + return; + } if (!term) { file = path.resolve(prefix, 'x');