Skip to content

Commit 67a010c

Browse files
fix unsupported version message not showing up
1 parent 1cf876c commit 67a010c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Logger from './libraries/Logger'
22
import * as os from 'node:os'
33
import Executor from "./libraries/Executor"
4-
import { satisfies, lt } from "semver"
4+
import { satisfies, lt, coerce } from "semver"
55
import { BinaryInfo, InternalServerOptions, ServerOptions } from '../types'
66
import getBinaryURL from './libraries/Version'
77
import MySQLVersions from './versions.json'
@@ -57,24 +57,24 @@ export async function createDB(opts?: ServerOptions) {
5757
binaryInfo = getBinaryURL(MySQLVersions, options.version, options)
5858
logger.log('Using MySQL binary version:', binaryInfo.version, 'from URL:', binaryInfo.url)
5959
} catch (e) {
60+
if (options.version && lt(coerce(options.version), MIN_SUPPORTED_MYSQL)) {
61+
//The difference between the throw here and the throw above is this throw is because the selected "version" is not supported.
62+
//The throw above is because the system-installed MySQL is out of date and "ignoreUnsupportedSystemVersion" is not set to true.
63+
throw `The selected version of MySQL (${options.version}) is not currently supported by this package. Please choose a different version to use.`
64+
}
65+
6066
logger.error(e)
6167
if (options.version) {
6268
throw `A MySQL version ${options.version} binary could not be found that supports your OS (${os.platform()} | ${os.version()} | ${os.release()}) and CPU architecture (${os.arch()}). Please check you have the latest version of mysql-memory-server. If the latest version still doesn't support the version you want to use, feel free to make a pull request to add support!`
6369
}
6470
throw `A MySQL binary could not be found that supports your OS (${os.platform()} | ${os.version()} | ${os.release()}) and CPU architecture (${os.arch()}). Please check you have the latest version of mysql-memory-server. If the latest version still doesn't support your OS and CPU architecture, feel free to make a pull request to add support!`
6571
}
6672

67-
if (lt(binaryInfo.version, MIN_SUPPORTED_MYSQL)) {
68-
//The difference between the throw here and the throw above is this throw is because the selected "version" is not supported.
69-
//The throw above is because the system-installed MySQL is out of date and "ignoreUnsupportedSystemVersion" is not set to true.
70-
throw `The selected version of MySQL (${options.version}) is not currently supported by this package. Please choose a different version to use.`
71-
}
72-
7373
try {
7474
binaryFilepath = await downloadBinary(binaryInfo, options, logger);
7575
} catch (error) {
7676
logger.error('Failed to download binary:', error)
77-
throw `Failed to download binary. The error was: "${error}"`
77+
throw `Failed to download binary. The error was: "${error}"`
7878
}
7979

8080
logger.log('Running downloaded binary')

0 commit comments

Comments
 (0)