Skip to content

Commit 75fa143

Browse files
committed
fix(DownloadUrl): added Mint download url (thanks to @StepanYurtsiv)
Related #38
1 parent b15a789 commit 75fa143

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/util/MongoBinaryDownloadUrl.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import getos from 'getos';
55

66
type OS = {
7-
release: string,
87
dist: string,
8+
release?: string,
99
};
1010

1111
const DOWNLOAD_URI = 'https://downloads.mongodb.org';
@@ -79,6 +79,8 @@ export default class MongoBinaryDownloadUrl {
7979
return this.getFedoraVersionString(os);
8080
} else if (/debian/i.test(os.dist)) {
8181
return this.getDebianVersionString(os);
82+
} else if (/mint/i.test(os.dist)) {
83+
return this.getMintVersionString(os);
8284
}
8385
throw new Error(`Cannot determine version string for ${JSON.stringify(os)}`);
8486
}
@@ -109,12 +111,15 @@ export default class MongoBinaryDownloadUrl {
109111

110112
getRhelVersionString(os: OS): string {
111113
let name: string = 'rhel';
112-
if (/^7/.test(os.release)) {
113-
name += '70';
114-
} else if (/^6/.test(os.release)) {
115-
name += '62';
116-
} else if (/^5/.test(os.release)) {
117-
name += '55';
114+
const { release } = os;
115+
if (release) {
116+
if (/^7/.test(release)) {
117+
name += '70';
118+
} else if (/^6/.test(release)) {
119+
name += '62';
120+
} else if (/^5/.test(release)) {
121+
name += '55';
122+
}
118123
}
119124
return name;
120125
}
@@ -124,6 +129,12 @@ export default class MongoBinaryDownloadUrl {
124129
return 'ubuntu1404';
125130
}
126131

132+
// eslint-disable-next-line no-unused-vars
133+
getMintVersionString(os: OS): string {
134+
// unfortunately getos doesn't return version for Mint
135+
return 'ubuntu1404';
136+
}
137+
127138
getSuseVersionString(os: any): string {
128139
const [release]: [string | null] = os.release.match(/(^11|^12)/) || [null];
129140

src/util/__tests__/MongoBinaryDownloadUrl-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,16 @@ describe('MongoBinaryDownloadUrl', () => {
142142
).toBe('debian81');
143143
});
144144
});
145+
146+
describe('getMintVersionString', () => {
147+
const downloadUrl = new MongoBinaryDownloadUrl({
148+
platform: 'linux',
149+
arch: 'x64',
150+
version: '3.4.4',
151+
});
152+
153+
it('should return an archive name for Linux Mint', () => {
154+
expect(downloadUrl.getMintVersionString({ dist: 'Linux Mint' })).toBe('ubuntu1404');
155+
});
156+
});
145157
});

0 commit comments

Comments
 (0)