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 11import path from "path" ;
22import os from "os" ;
33import 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" ;
66
77// From: https://github.com/mongodb-js/mongosh/blob/main/packages/cli-repl/src/arg-parser.ts
88const OPTIONS = {
@@ -286,21 +286,9 @@ export function setupUserConfig({
286286 userConfig . loggers = commaSeparatedToArray ( userConfig . loggers ) ;
287287
288288 if ( userConfig . connectionString && userConfig . connectionSpecifier ) {
289- delete userConfig . connectionString ;
289+ const connectionInfo = generateConnectionInfoFromCliArgs ( userConfig ) ;
290+ userConfig . connectionString = connectionInfo . connectionString ;
290291 }
291292
292293 return userConfig ;
293294}
294-
295- /**
296- readConcern: {
297- level: settings.readConcern,
298- },
299- readPreference: settings.readPreference,
300- writeConcern: {
301- w: settings.writeConcern,
302- },
303- timeoutMS: settings.timeoutMS,
304- proxy: { useEnvironmentVariableProxies: true },
305- applyProxyToOIDC: true,
306- **/
Original file line number Diff line number Diff line change 11export { Server , type ServerOptions } from "./server.js" ;
22export { Telemetry } from "./telemetry/telemetry.js" ;
33export { 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", () => {
404404 defaults : { } ,
405405 } ) ;
406406
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+ ) ;
408411 expect ( actual . connectionSpecifier ) . toBe ( "mongodb://localhost" ) ;
409412 } ) ;
410413 } ) ;
You can’t perform that action at this time.
0 commit comments