Skip to content

Commit 613e670

Browse files
committed
fix(MongoBinary::getPath): check that "stdout" actually exists
because it seemingly can be undefined, see #742#issuecomment-2528284865
1 parent c0975c3 commit 613e670

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ export class MongoBinary {
8989
if (!isNullOrUndefined(binaryPath)) {
9090
log(`getPath: Spawning binaryPath "${binaryPath}" to get version`);
9191
const spawnOutput = spawnSync(binaryPath, ['--version'])
92-
.stdout.toString()
92+
// NOTE: "stdout" seemingly can be "undefined", see https://github.com/typegoose/mongodb-memory-server/issues/742#issuecomment-2528284865
93+
.stdout?.toString()
9394
// this regex is to match the first line of the "mongod --version" output "db version v4.0.25" OR "db version v4.2.19-11-ge2f2736"
9495
.match(/^\s*db\s+version\s+v?(\d+\.\d+\.\d+)(-\d*)?(-[a-zA-Z0-9].*)?\s*$/im);
9596

0 commit comments

Comments
 (0)