Skip to content

Commit 4b3dc91

Browse files
committed
fix(Flowtype): Fix Flow declarations
1 parent 829be44 commit 4b3dc91

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import getport from 'get-port';
88
tmp.setGracefulCleanup();
99

1010
export type MongoMemoryServerOptsT = {
11-
port?: number,
11+
port?: ?number,
1212
storageEngine?: string,
1313
dbPath?: string,
1414
autoStart?: boolean,
@@ -21,9 +21,13 @@ export type MongoInstanceDataT = {
2121
uri: string,
2222
storageEngine: string,
2323
mongodCli: MongodHelper,
24+
tmpDir?: {
25+
name: string,
26+
removeCallback: Function,
27+
},
2428
};
2529

26-
async function generateConnectionString(port: string, dbName: ?string): Promise<string> {
30+
async function generateConnectionString(port: number, dbName: ?string): Promise<string> {
2731
const db = dbName || (await uuid());
2832
return `mongodb://localhost:${port}/${db}`;
2933
}
@@ -118,7 +122,7 @@ export default class MongoDBMemoryServer {
118122
}
119123

120124
async stop(): Promise<boolean> {
121-
const { mongodCli, port, tmpDir } = await this.getInstanceData();
125+
const { mongodCli, port, tmpDir } = (await this.getInstanceData(): MongoInstanceDataT);
122126

123127
if (mongodCli && mongodCli.mongoBin.childProcess) {
124128
// .mongoBin.childProcess.connected
@@ -147,7 +151,7 @@ export default class MongoDBMemoryServer {
147151
}
148152

149153
async getUri(otherDbName?: string | boolean = false): Promise<string> {
150-
const { uri, port } = await this.getInstanceData();
154+
const { uri, port } = (await this.getInstanceData(): MongoInstanceDataT);
151155

152156
// IF true OR string
153157
if (otherDbName) {
@@ -167,12 +171,12 @@ export default class MongoDBMemoryServer {
167171
}
168172

169173
async getPort(): Promise<number> {
170-
const { port } = await this.getInstanceData();
174+
const { port } = (await this.getInstanceData(): MongoInstanceDataT);
171175
return port;
172176
}
173177

174178
async getDbPath(): Promise<string> {
175-
const { port } = await this.getInstanceData();
176-
return port;
179+
const { dbPath } = (await this.getInstanceData(): MongoInstanceDataT);
180+
return dbPath;
177181
}
178182
}

0 commit comments

Comments
 (0)