Skip to content

Commit 0bec0bf

Browse files
committed
fix(resolveConfig): findPackageJson: resolve file paths directly
fixes #440
1 parent ceea1a7 commit 0bec0bf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/mongodb-memory-server-core/src/util/resolveConfig.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import camelCase from 'camelcase';
22
import finder from 'find-package-json';
33
import debug from 'debug';
4+
import * as path from 'path';
45

56
const log = debug('MongoMS:ResolveConfig');
67

@@ -44,6 +45,22 @@ export function findPackageJson(directory?: string): Record<string, string> {
4445
log(`Using package.json at "${finderIterator.filename}"`);
4546
packageJsonConfig = finderIterator.value?.config?.mongodbMemoryServer ?? {};
4647

48+
// block for all file-path resolving
49+
{
50+
// These are so that "camelCase" dosnt get executed much & de-duplicate code
51+
// "cc*" means "camelcase"
52+
const ccDownloadDir = camelCase(ResolveConfigVariables.DOWNLOAD_DIR);
53+
const ccSystemBinary = camelCase(ResolveConfigVariables.SYSTEM_BINARY);
54+
55+
if (ccDownloadDir in packageJsonConfig) {
56+
packageJsonConfig[ccDownloadDir] = path.resolve(packageJsonConfig[ccDownloadDir]);
57+
}
58+
59+
if (ccSystemBinary in packageJsonConfig) {
60+
packageJsonConfig[ccSystemBinary] = path.resolve(packageJsonConfig[ccSystemBinary]);
61+
}
62+
}
63+
4764
return packageJsonConfig;
4865
}
4966
findPackageJson();

0 commit comments

Comments
 (0)