diff --git a/src/index.ts b/src/index.ts index 4ecf4c8f..1e60cf2a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -49,12 +49,6 @@ export async function createDB(opts?: ServerOptions) { throw `A version of MySQL is installed on your system that is not supported by this package. If you want to download a MySQL binary instead of getting this error, please set the option "ignoreUnsupportedSystemVersion" to true.` } - if (options.version && lt(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.log('Version currently installed:', version) if (version === null || (options.version && !satisfies(version.version, options.version)) || unsupportedMySQLIsInstalled) { let binaryInfo: BinaryInfo; @@ -70,6 +64,12 @@ export async function createDB(opts?: ServerOptions) { 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) {