Skip to content

Commit

Permalink
add installedOnSystem boolean to DownloadedMySQLVersion type
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian-Webster committed Dec 3, 2024
1 parent 09ca65b commit 0e5141f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function createDB(opts?: ServerOptions) {
}

logger.log('Running downloaded binary')
return await executor.startMySQL(options, {path: binaryFilepath, version: binaryInfo.version})
return await executor.startMySQL(options, {path: binaryFilepath, version: binaryInfo.version, installedOnSystem: false})
} else {
logger.log(version)
return await executor.startMySQL(options, version)
Expand Down
12 changes: 6 additions & 6 deletions src/libraries/Executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as fsPromises from 'fs/promises';
import * as fs from 'fs';
import Logger from "./Logger";
import { GenerateRandomPort } from "./Port";
import { ExecuteFileReturn, InstalledMySQLVersion, InternalServerOptions, MySQLDB } from "../../types";
import { ExecuteFileReturn, DownloadedMySQLVersion, InternalServerOptions, MySQLDB } from "../../types";
import {normalize as normalizePath, resolve as resolvePath} from 'path'
import { lockFile, waitForLock } from "./FileLock";
import { onExit } from "signal-exit";
Expand Down Expand Up @@ -212,7 +212,7 @@ class Executor {
})
}

getMySQLVersion(preferredVersion?: string): Promise<InstalledMySQLVersion | null> {
getMySQLVersion(preferredVersion?: string): Promise<DownloadedMySQLVersion | null> {
return new Promise(async (resolve, reject) => {
if (process.platform === 'win32') {
try {
Expand All @@ -225,7 +225,7 @@ class Executor {

this.logger.log(servers)

const versions: {version: string, path: string}[] = []
const versions: DownloadedMySQLVersion[] = []

for (const dir of servers) {
const path = `${process.env.PROGRAMFILES}\\MySQL\\${dir}\\bin\\mysqld`
Expand All @@ -241,7 +241,7 @@ class Executor {
if (version === null) {
return reject('Could not get MySQL version')
} else {
versions.push({version: version.version, path})
versions.push({version: version.version, path, installedOnSystem: true})
}
}

Expand All @@ -266,7 +266,7 @@ class Executor {
if (version === null) {
reject('Could not get installed MySQL version')
} else {
resolve({version: version.version, path: 'mysqld'})
resolve({version: version.version, path: 'mysqld', installedOnSystem: true})
}
}
}
Expand Down Expand Up @@ -422,7 +422,7 @@ class Executor {
this.logger.log('Finished writing init file')
}

async startMySQL(options: InternalServerOptions, installedMySQLBinary: InstalledMySQLVersion): Promise<MySQLDB> {
async startMySQL(options: InternalServerOptions, installedMySQLBinary: DownloadedMySQLVersion): Promise<MySQLDB> {
this.version = installedMySQLBinary.version
this.removeExitHandler = onExit(() => {
if (options._DO_NOT_USE_cli) {
Expand Down
5 changes: 3 additions & 2 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ export type MySQLVersion = {
url: string
}

export type InstalledMySQLVersion = {
export type DownloadedMySQLVersion = {
version: string,
path: string
path: string,
installedOnSystem: boolean
}

export type BinaryInfo = {
Expand Down

0 comments on commit 0e5141f

Please sign in to comment.