You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
742 B
JavaScript
33 lines
742 B
JavaScript
"use strict";
|
|
|
|
const Promise = require("bluebird");
|
|
|
|
const execFileAsync = require("./exec-file-async");
|
|
|
|
module.exports = function ldd(path) {
|
|
return Promise.try(() => {
|
|
return execFileAsync("ldd", [ path ]);
|
|
}).then(({ stdout, stderr }) => {
|
|
return stdout.split("\n").filter((line) => {
|
|
return (line.trim().length > 0);
|
|
}).map((line) => {
|
|
let match = /^\s*(\S+)\s+=>\s+(.+)$/.exec(line);
|
|
|
|
if (match == null) {
|
|
if (!line.includes(".so")) {
|
|
throw new Error(`Encountered unexpected output from ldd: ${line}`);
|
|
}
|
|
} else {
|
|
return {
|
|
library: match[1],
|
|
location: (match[2] === "not found")
|
|
? null
|
|
: match[2]
|
|
};
|
|
}
|
|
}).filter((result) => {
|
|
return (result != null);
|
|
});
|
|
});
|
|
};
|