From 9105c80eb74d34352b7593cc14a09297502e4597 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 4 Apr 2015 06:56:01 -0700 Subject: [PATCH] improve w3m search. do not search for w3mimgdisplay in example. fixes #119. --- README.md | 3 ++- lib/widget.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 44ffd93..21ac839 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,8 @@ var icon = blessed.image({ left: 0, width: 'shrink', height: 'shrink', - file: __dirname + '/my-program-icon.png' + file: __dirname + '/my-program-icon.png', + search: false }); // If our box is clicked, change the content. diff --git a/lib/widget.js b/lib/widget.js index 5d03b7c..a73dd2e 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -7995,7 +7995,9 @@ function Image(options) { if (fs.existsSync(Image.w3mdisplay)) { Image.hasW3MDisplay = true; } else if (options.search !== false) { - var file = findFile('/', 'w3mimgdisplay'); + var file = findFile('/usr', 'w3mimgdisplay') + || findFile('/lib', 'w3mimgdisplay') + || findFile('/bin', 'w3mimgdisplay'); if (file) { Image.hasW3MDisplay = true; Image.w3mdisplay = file; @@ -8456,12 +8458,12 @@ function findFile(start, target) { } try { - stat = fs.statSync((dir === '/' ? '' : dir) + '/' + file); + stat = fs.lstatSync((dir === '/' ? '' : dir) + '/' + file); } catch (e) { stat = null; } - if (stat && stat.isDirectory()) { + if (stat && stat.isDirectory() && !stat.isSymbolicLink()) { out = read((dir === '/' ? '' : dir) + '/' + file); if (out) return out; }