Skip to content

Commit 3d1ef62

Browse files
authored
Build: use brew --prefix to get brew package config path (#4505)
1 parent fff7431 commit 3d1ef62

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

lib/libvips.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,24 @@ const globalLibvipsVersion = () => {
145145
}
146146
};
147147

148+
const getBrewPkgConfigPath = () => {
149+
try {
150+
const brewPrefix = (spawnSync('brew', ['--prefix'], { encoding: 'utf8' }).stdout || '').trim();
151+
if (brewPrefix) {
152+
return `${brewPrefix}/lib/pkgconfig`;
153+
}
154+
} catch (_err) {
155+
// ignore
156+
}
157+
return undefined;
158+
};
159+
148160
/* node:coverage enable */
149161

150162
const pkgConfigPath = () => {
151163
if (process.platform !== 'win32') {
152-
/* node:coverage ignore next 4 */
153-
const brewPkgConfigPath = spawnSync(
154-
'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',
155-
spawnSyncOptions
156-
).stdout || '';
157164
return [
158-
brewPkgConfigPath.trim(),
165+
getBrewPkgConfigPath(),
159166
process.env.PKG_CONFIG_PATH,
160167
'/usr/local/lib/pkgconfig',
161168
'/usr/lib/pkgconfig',

0 commit comments

Comments
 (0)