Skip to content

Commit

Permalink
fix unsupported version message not showing up
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian-Webster committed Dec 5, 2024
1 parent 1cf876c commit 67a010c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Logger from './libraries/Logger'
import * as os from 'node:os'
import Executor from "./libraries/Executor"
import { satisfies, lt } from "semver"
import { satisfies, lt, coerce } from "semver"
import { BinaryInfo, InternalServerOptions, ServerOptions } from '../types'
import getBinaryURL from './libraries/Version'
import MySQLVersions from './versions.json'
Expand Down Expand Up @@ -57,24 +57,24 @@ export async function createDB(opts?: ServerOptions) {
binaryInfo = getBinaryURL(MySQLVersions, options.version, options)
logger.log('Using MySQL binary version:', binaryInfo.version, 'from URL:', binaryInfo.url)
} catch (e) {
if (options.version && lt(coerce(options.version), MIN_SUPPORTED_MYSQL)) {
//The difference between the throw here and the throw above is this throw is because the selected "version" is not supported.
//The throw above is because the system-installed MySQL is out of date and "ignoreUnsupportedSystemVersion" is not set to true.
throw `The selected version of MySQL (${options.version}) is not currently supported by this package. Please choose a different version to use.`
}

logger.error(e)
if (options.version) {
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!`
}
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!`
}

if (lt(binaryInfo.version, MIN_SUPPORTED_MYSQL)) {
//The difference between the throw here and the throw above is this throw is because the selected "version" is not supported.
//The throw above is because the system-installed MySQL is out of date and "ignoreUnsupportedSystemVersion" is not set to true.
throw `The selected version of MySQL (${options.version}) is not currently supported by this package. Please choose a different version to use.`
}

try {
binaryFilepath = await downloadBinary(binaryInfo, options, logger);
} catch (error) {
logger.error('Failed to download binary:', error)
throw `Failed to download binary. The error was: "${error}"`
throw `Failed to download binary. The error was: "${error}"`
}

logger.log('Running downloaded binary')
Expand Down

0 comments on commit 67a010c

Please sign in to comment.