Skip to content

Commit 66197db

Browse files
guillaumervlsnodkz
authored andcommitted
fix: download path in post-install script
Closes #101
1 parent 399725d commit 66197db

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/util/MongoBinary.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ export default class MongoBinary {
3030
process.env?.MONGOMS_DOWNLOAD_DIR ||
3131
(fs.existsSync(legacyDLDir)
3232
? legacyDLDir
33-
: path.resolve(findCacheDir({ name: 'mongodb-memory-server' }), 'mongodb-binaries')),
33+
: path.resolve(
34+
findCacheDir({
35+
name: 'mongodb-memory-server',
36+
// if we're in postinstall script, npm will set the cwd too deep
37+
cwd: new RegExp(`node_modules${path.sep}mongodb-memory-server$`).test(process.cwd())
38+
? path.resolve(process.cwd(), '..', '..')
39+
: process.cwd(),
40+
}),
41+
'mongodb-binaries'
42+
)),
3443
platform: process.env?.MONGOMS_PLATFORM || os.platform(),
3544
arch: process.env?.MONGOMS_ARCH || os.arch(),
3645
version: process.env?.MONGOMS_VERSION || 'latest',

0 commit comments

Comments
 (0)