File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
packages/mongodb-memory-server-core/src/util Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,13 @@ export default class MongoBinary {
103103
104104 static async getPath ( opts : MongoBinaryOpts = { } ) : Promise < string > {
105105 const legacyDLDir = path . resolve ( os . homedir ( ) , '.cache/mongodb-binaries' ) ;
106+
107+ // if we're in postinstall script, npm will set the cwd too deep
108+ let nodeModulesDLDir = process . cwd ( ) ;
109+ while ( new RegExp ( `node_modules${ path . sep } mongodb-memory-server` ) . test ( nodeModulesDLDir ) ) {
110+ nodeModulesDLDir = path . resolve ( nodeModulesDLDir , '..' , '..' ) ;
111+ }
112+
106113 const defaultOptions = {
107114 downloadDir :
108115 process . env . MONGOMS_DOWNLOAD_DIR ||
@@ -111,10 +118,7 @@ export default class MongoBinary {
111118 : path . resolve (
112119 findCacheDir ( {
113120 name : 'mongodb-memory-server' ,
114- // if we're in postinstall script, npm will set the cwd too deep
115- cwd : new RegExp ( `node_modules${ path . sep } mongodb-memory-server$` ) . test ( process . cwd ( ) )
116- ? path . resolve ( process . cwd ( ) , '..' , '..' )
117- : process . cwd ( ) ,
121+ cwd : nodeModulesDLDir ,
118122 } ) || '' ,
119123 'mongodb-binaries'
120124 ) ) ,
You can’t perform that action at this time.
0 commit comments