Skip to content

Commit

Permalink
fix: resolve lmdb binaries correctly (#327)
Browse files Browse the repository at this point in the history
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
ascorbic and kodiakhq[bot] authored Mar 21, 2022
1 parent e721c27 commit c6c162b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions plugin/src/helpers/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,23 @@ export const relocateBinaries = async (baseDir: string): Promise<void> => {
return
}

const lmdbPath = findModuleFromBase({
let lmdbPath = findModuleFromBase({
paths: [gatsbyPath, baseDir],
candidates: ['lmdb-store', 'lmdb'],
candidates: ['lmdb-store'],
})

if (!lmdbPath) {
console.log(`Could not find lmdb module in ${gatsbyPath}`)
return
const modulePath = findModuleFromBase({
paths: [gatsbyPath, baseDir],
candidates: ['lmdb'],
})
if (modulePath) {
// The lmdb package resolves to a subdirectory of the module, and we need the root
lmdbPath = dirname(modulePath)
} else {
console.log(`Could not find lmdb module in ${gatsbyPath}`)
return
}
}

console.log(
Expand All @@ -135,6 +144,8 @@ export const relocateBinaries = async (baseDir: string): Promise<void> => {
if (existsSync(from) && !existsSync(to)) {
console.log(`Copying ${from} to ${to}`)
await copyFile(from, to)
} else {
console.log(`Skipping ${from}`)
}
}
}

0 comments on commit c6c162b

Please sign in to comment.