Skip to content

Commit 4d776e0

Browse files
committed
allow connection string to be captured by the caller
1 parent f52db8f commit 4d776e0

File tree

1 file changed

+12
-5
lines changed
  • packages/mongodb-runner/src

1 file changed

+12
-5
lines changed

packages/mongodb-runner/src/cli.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,29 @@ import type { MongoClientOptions } from 'mongodb';
115115
async function start() {
116116
const { cluster, id } = await utilities.start(argv, args);
117117
const cs = new ConnectionString(cluster.connectionString);
118-
console.log(`Server started and running at ${cs.toString()}`);
118+
// Only the connection string should print to stdout so it can be captured
119+
// by a calling process.
120+
console.error(`Server started and running at ${cs.toString()}`);
119121
if (cluster.oidcIssuer) {
120122
cs.typedSearchParams<MongoClientOptions>().set(
121123
'authMechanism',
122124
'MONGODB-OIDC',
123125
);
124-
console.log(`OIDC provider started and running at ${cluster.oidcIssuer}`);
125-
console.log(`Server connection string with OIDC auth: ${cs.toString()}`);
126+
console.error(
127+
`OIDC provider started and running at ${cluster.oidcIssuer}`,
128+
);
129+
console.error(
130+
`Server connection string with OIDC auth: ${cs.toString()}`,
131+
);
126132
}
127-
console.log('Run the following command to stop the instance:');
128-
console.log(
133+
console.error('Run the following command to stop the instance:');
134+
console.error(
129135
`${argv.$0} stop --id=${id}` +
130136
(argv.runnerDir !== defaultRunnerDir
131137
? `--runnerDir=${argv.runnerDir}`
132138
: ''),
133139
);
140+
console.log(cs.toString());
134141
cluster.unref();
135142
}
136143

0 commit comments

Comments
 (0)