@@ -50,7 +50,7 @@ let packageJsonConfig: Record<string, string> = {};
5050 * @param directory Set an custom directory to search the config in (default: process.cwd())
5151 */
5252export function findPackageJson ( directory ?: string ) : Record < string , string > {
53- let filename : string | undefined ;
53+ let filepath : string | undefined ;
5454 for ( const filename of findSync ( directory || process . cwd ( ) ) ) {
5555 log ( `findPackageJson: Found package.json at "${ filename } "` ) ;
5656 const readout : Record < string , any > = JSON . parse ( readFileSync ( filename ) . toString ( ) ) ;
@@ -60,29 +60,24 @@ export function findPackageJson(directory?: string): Record<string, string> {
6060
6161 // the optional chaining is needed, because typescript wont accept an "isNullOrUndefined" in the if with "&& Object.keys"
6262 packageJsonConfig = readout ?. config ?. mongodbMemoryServer ;
63+ filepath = path . dirname ( filename ) ;
6364 break ;
6465 }
6566 }
6667
6768 // block for all file-path resolving
68- if ( filename ) {
69+ if ( filepath ) {
6970 // These are so that "camelCase" doesnt get executed much & de-duplicate code
7071 // "cc*" means "camelcase"
7172 const ccDownloadDir = camelCase ( ResolveConfigVariables . DOWNLOAD_DIR ) ;
7273 const ccSystemBinary = camelCase ( ResolveConfigVariables . SYSTEM_BINARY ) ;
7374
7475 if ( ccDownloadDir in packageJsonConfig ) {
75- packageJsonConfig [ ccDownloadDir ] = path . resolve (
76- path . dirname ( filename ) ,
77- packageJsonConfig [ ccDownloadDir ]
78- ) ;
76+ packageJsonConfig [ ccDownloadDir ] = path . resolve ( filepath , packageJsonConfig [ ccDownloadDir ] ) ;
7977 }
8078
8179 if ( ccSystemBinary in packageJsonConfig ) {
82- packageJsonConfig [ ccSystemBinary ] = path . resolve (
83- path . dirname ( filename ) ,
84- packageJsonConfig [ ccSystemBinary ]
85- ) ;
80+ packageJsonConfig [ ccSystemBinary ] = path . resolve ( filepath , packageJsonConfig [ ccSystemBinary ] ) ;
8681 }
8782 }
8883
0 commit comments