Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 18e5337

Browse files
fedotovLoneRifle
authored andcommitted
Reuse IMongoDBDownloadOptions from mongodb-download (#56)
1 parent db4678b commit 18e5337

File tree

4 files changed

+11
-25
lines changed

4 files changed

+11
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
dist
44
*.log
55
*.swp
6+
.idea

src/mongo-bins.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
const Debug: any = require('debug');
22
import { resolve as resolvePath } from 'path';
33
import { SpawnOptions, ChildProcess, spawn as spawnChild } from 'child_process';
4-
import { IMongoDBDownloadOpts } from './mongod-helper';
4+
import { IMongoDBDownloadOptions } from 'mongodb-download';
55
import { MongoDBPrebuilt } from './mongodb-prebuilt';
66
import { MongoSupervise } from './mongodb-supervise';
7-
import { MongoDBDownload } from 'mongodb-download';
87

98
export class MongoBins {
10-
command: string;
11-
execPath: string;
129
debug: any;
1310
childProcess: ChildProcess;
1411
mongoSupervice: MongoSupervise;
1512
mongoDBPrebuilt: MongoDBPrebuilt;
1613

1714
constructor(
18-
command: string,
15+
public command: string,
1916
public commandArguments: string[] = [],
2017
public spawnOptions: SpawnOptions = {},
21-
22-
downloadOptions?: IMongoDBDownloadOpts
18+
downloadOptions?: Partial<IMongoDBDownloadOptions>
2319
) {
2420

2521
this.debug = Debug(`mongodb-prebuilt-MongoBins`);
26-
this.command = command;
22+
2723
if (downloadOptions) {
2824
this.mongoDBPrebuilt = new MongoDBPrebuilt(downloadOptions);
2925
} else {
3026
this.mongoDBPrebuilt = new MongoDBPrebuilt();
3127
}
32-
3328
}
3429

3530
run(): Promise<boolean> {
@@ -87,4 +82,4 @@ export class MongoBins {
8782
});
8883
}
8984

90-
}
85+
}

src/mongod-helper.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
import { MongoBins } from './mongo-bins';
2+
import { IMongoDBDownloadOptions } from 'mongodb-download';
23
const Debug: any = require('debug');
34

45
const COMMAND: string = "mongod";
56

6-
export interface IMongoDBDownloadOpts {
7-
platform?: string;
8-
arch?: string;
9-
version?: string;
10-
downloadDir?: string;
11-
http?: any;
12-
}
13-
147
export class MongodHelper {
158
mongoBin: MongoBins;
169
debug: any;
1710

1811
private resolveLink: (response: boolean) => void = () => { };
1912
private rejectLink: (response: string) => void = () => { };
2013

21-
constructor(commandArguments: string[] = [], downloadOptions?: IMongoDBDownloadOpts) {
14+
constructor(commandArguments: string[] = [], downloadOptions?: Partial<IMongoDBDownloadOptions>) {
2215
if (downloadOptions) {
2316
this.mongoBin = new MongoBins(COMMAND, commandArguments, {}, downloadOptions);
2417
} else {

src/mongodb-prebuilt.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@ const Debug: any = require('debug');
22
const { Glob } = require("glob");
33
import { resolve as resolvePath } from 'path';
44
import { homedir as osHomeDir } from 'os';
5-
import { MongoDBDownload } from 'mongodb-download';
6-
import { IMongoDBDownloadOpts } from './mongod-helper';
7-
5+
import { IMongoDBDownloadOptions, MongoDBDownload } from 'mongodb-download';
86

97
export class MongoDBPrebuilt {
108
private debug: any;
119
private binPath: string;
1210

13-
constructor(public mongoDBDownload?: MongoDBDownload | IMongoDBDownloadOpts) {
11+
constructor(public mongoDBDownload?: MongoDBDownload | Partial<IMongoDBDownloadOptions>) {
1412
this.debug = Debug('mongodb-prebuilt-MongoDBPrebuilt');
1513

1614
if (!this.mongoDBDownload || !(this.mongoDBDownload instanceof MongoDBDownload)) {
17-
const downloadOpts: IMongoDBDownloadOpts = this.mongoDBDownload as IMongoDBDownloadOpts || {
15+
const downloadOpts: Partial<IMongoDBDownloadOptions> = this.mongoDBDownload as Partial<IMongoDBDownloadOptions> || {
1816
downloadDir: this.getHomeDirectory()
1917
};
2018
downloadOpts.downloadDir = downloadOpts.downloadDir || this.getHomeDirectory();
@@ -77,4 +75,3 @@ export class MongoDBPrebuilt {
7775
}
7876

7977
}
80-

0 commit comments

Comments
 (0)