Skip to content

Commit 04b0ee9

Browse files
committed
refactor(MongoBinaryDownloadUrl): minify "getUbuntuVersionString"
1 parent f6ca651 commit 04b0ee9

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -301,32 +301,24 @@ export class MongoBinaryDownloadUrl {
301301
let name = 'ubuntu';
302302
const ubuntuVer: string[] = os.release ? os.release.split('.') : [];
303303
const majorVer: number = parseInt(ubuntuVer[0], 10);
304-
// const minorVer: string = ubuntuVer[1];
305-
306-
if (os.release === '12.04') {
307-
name += '1204';
308-
} else if (os.release === '14.04') {
309-
name += '1404';
310-
} else if (os.release === '14.10') {
311-
name += '1410-clang';
312-
} else if (majorVer === 14) {
313-
name += '1404';
314-
} else if (os.release === '16.04') {
315-
name += '1604';
316-
} else if (majorVer === 16) {
317-
name += '1604';
304+
// for all cases where its just "10.10" -> "1010"
305+
// and because the "04" version always exists for ubuntu, use that as default
306+
let version = `${majorVer || 14}04`;
307+
308+
if (os.release === '14.10') {
309+
version = '1410-clang';
318310
} else if (majorVer >= 18) {
319311
if (this.version && this.version.indexOf('3.') === 0) {
320-
// For MongoDB 3.x using 1604 binaries, download distro does not have builds for Ubuntu 1804
312+
// For MongoDB 3.x using 1604 binaries, download distro does not have builds for Ubuntu 1804 AND 2004
321313
// https://www.mongodb.org/dl/linux/x86_64-ubuntu1604
322-
name += '1604';
314+
version = '1604';
323315
} else {
324316
// See fulllist of versions https://www.mongodb.org/dl/linux/x86_64-ubuntu1804
325-
name += '1804';
317+
// For MongoDB <4.4 using 1804 binaries, because 2004 dosnt have anything below 4.4
318+
version = '1804';
326319
}
327-
} else {
328-
name += '1404';
329320
}
321+
name += version;
330322
return name;
331323
}
332324

0 commit comments

Comments
 (0)