File tree Expand file tree Collapse file tree 3 files changed +9
-18
lines changed Expand file tree Collapse file tree 3 files changed +9
-18
lines changed Original file line number Diff line number Diff line change 1
1
import path from "path" ;
2
2
import os from "os" ;
3
3
import argv from "yargs-parser" ;
4
- import type { CliOptions } from "@mongosh/arg-parser" ;
5
- import type { ConnectionInfo } from "@mongosh/arg-parser" ;
4
+ import type { CliOptions , ConnectionInfo } from "@mongosh/arg-parser" ;
5
+ import { generateConnectionInfoFromCliArgs } from "@mongosh/arg-parser" ;
6
6
7
7
// From: https://github.com/mongodb-js/mongosh/blob/main/packages/cli-repl/src/arg-parser.ts
8
8
const OPTIONS = {
@@ -296,21 +296,9 @@ export function setupUserConfig({
296
296
userConfig . loggers = commaSeparatedToArray ( userConfig . loggers ) ;
297
297
298
298
if ( userConfig . connectionString && userConfig . connectionSpecifier ) {
299
- delete userConfig . connectionString ;
299
+ const connectionInfo = generateConnectionInfoFromCliArgs ( userConfig ) ;
300
+ userConfig . connectionString = connectionInfo . connectionString ;
300
301
}
301
302
302
303
return userConfig ;
303
304
}
304
-
305
- /**
306
- readConcern: {
307
- level: settings.readConcern,
308
- },
309
- readPreference: settings.readPreference,
310
- writeConcern: {
311
- w: settings.writeConcern,
312
- },
313
- timeoutMS: settings.timeoutMS,
314
- proxy: { useEnvironmentVariableProxies: true },
315
- applyProxyToOIDC: true,
316
- **/
Original file line number Diff line number Diff line change 1
1
export { Server , type ServerOptions } from "./server.js" ;
2
2
export { Telemetry } from "./telemetry/telemetry.js" ;
3
3
export { Session , type SessionOptions } from "./common/session.js" ;
4
- export type { UserConfig , ConnectOptions } from "./common/config.js" ;
4
+ export type { UserConfig } from "./common/config.js" ;
Original file line number Diff line number Diff line change @@ -404,7 +404,10 @@ describe("config", () => {
404
404
defaults : { } ,
405
405
} ) ;
406
406
407
- expect ( actual . connectionString ) . toBe ( undefined ) ;
407
+ // the shell specifies directConnection=true and serverSelectionTimeoutMS=2000 by default
408
+ expect ( actual . connectionString ) . toBe (
409
+ "mongodb://localhost/?directConnection=true&serverSelectionTimeoutMS=2000"
410
+ ) ;
408
411
expect ( actual . connectionSpecifier ) . toBe ( "mongodb://localhost" ) ;
409
412
} ) ;
410
413
} ) ;
You can’t perform that action at this time.
0 commit comments