Skip to content

Commit 59dee5b

Browse files
committed
fix for #151, fall back to find if pkg-config returns nothing
1 parent 2fc0fe0 commit 59dee5b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/ozwpaths.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ function getConfigItem(item) {
6363
if (usepkgconfig) {
6464
var cmdfmt = "pkg-config --variable=%s libopenzwave";
6565
var cmd = util.format(cmdfmt, item);
66-
return (cp.execSync(cmd).toString().split('\n')[0]);
67-
} else {
68-
// 2. try using find
69-
var cmdfmt = "find %s -name %s 2>/dev/null";
70-
var fp = configs[item].findpattern;
71-
for (var i in configs[item].locations) {
72-
var loc = configs[item].locations[i];
73-
if (!(loc && fs.existsSync(loc))) continue;
74-
var cmd = util.format(cmdfmt, loc, fp);
75-
var dir = doScript(cmd, true);
76-
if (!dir) continue;
77-
return path.dirname(dir.split('\n')[0]);
78-
}
66+
var result = cp.execSync(cmd).toString().split('\n')[0];
67+
if (result) return (result);
68+
}
69+
// 2. if pkg-config does NOT yeild a value, try using find
70+
var cmdfmt = "find %s -name %s 2>/dev/null";
71+
var fp = configs[item].findpattern;
72+
for (var i in configs[item].locations) {
73+
var loc = configs[item].locations[i];
74+
if (!(loc && fs.existsSync(loc))) continue;
75+
var cmd = util.format(cmdfmt, loc, fp);
76+
var dir = doScript(cmd, true);
77+
if (!dir) continue;
78+
return path.dirname(dir.split('\n')[0]);
7979
}
8080
}
8181

0 commit comments

Comments
 (0)