|
1 | 1 | import Logger from './libraries/Logger' |
2 | 2 | import * as os from 'node:os' |
3 | 3 | import Executor from "./libraries/Executor" |
4 | | -import { satisfies, lt } from "semver" |
| 4 | +import { satisfies, lt, coerce } from "semver" |
5 | 5 | import { BinaryInfo, InternalServerOptions, ServerOptions } from '../types' |
6 | 6 | import getBinaryURL from './libraries/Version' |
7 | 7 | import MySQLVersions from './versions.json' |
@@ -57,24 +57,24 @@ export async function createDB(opts?: ServerOptions) { |
57 | 57 | binaryInfo = getBinaryURL(MySQLVersions, options.version, options) |
58 | 58 | logger.log('Using MySQL binary version:', binaryInfo.version, 'from URL:', binaryInfo.url) |
59 | 59 | } 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 | + |
60 | 66 | logger.error(e) |
61 | 67 | if (options.version) { |
62 | 68 | 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!` |
63 | 69 | } |
64 | 70 | 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!` |
65 | 71 | } |
66 | 72 |
|
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 | | - |
73 | 73 | try { |
74 | 74 | binaryFilepath = await downloadBinary(binaryInfo, options, logger); |
75 | 75 | } catch (error) { |
76 | 76 | 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}"` |
78 | 78 | } |
79 | 79 |
|
80 | 80 | logger.log('Running downloaded binary') |
|
0 commit comments