Skip to content

Commit 0e5141f

Browse files
add installedOnSystem boolean to DownloadedMySQLVersion type
1 parent 09ca65b commit 0e5141f

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export async function createDB(opts?: ServerOptions) {
7878
}
7979

8080
logger.log('Running downloaded binary')
81-
return await executor.startMySQL(options, {path: binaryFilepath, version: binaryInfo.version})
81+
return await executor.startMySQL(options, {path: binaryFilepath, version: binaryInfo.version, installedOnSystem: false})
8282
} else {
8383
logger.log(version)
8484
return await executor.startMySQL(options, version)

src/libraries/Executor.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as fsPromises from 'fs/promises';
55
import * as fs from 'fs';
66
import Logger from "./Logger";
77
import { GenerateRandomPort } from "./Port";
8-
import { ExecuteFileReturn, InstalledMySQLVersion, InternalServerOptions, MySQLDB } from "../../types";
8+
import { ExecuteFileReturn, DownloadedMySQLVersion, InternalServerOptions, MySQLDB } from "../../types";
99
import {normalize as normalizePath, resolve as resolvePath} from 'path'
1010
import { lockFile, waitForLock } from "./FileLock";
1111
import { onExit } from "signal-exit";
@@ -212,7 +212,7 @@ class Executor {
212212
})
213213
}
214214

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

226226
this.logger.log(servers)
227227

228-
const versions: {version: string, path: string}[] = []
228+
const versions: DownloadedMySQLVersion[] = []
229229

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

@@ -266,7 +266,7 @@ class Executor {
266266
if (version === null) {
267267
reject('Could not get installed MySQL version')
268268
} else {
269-
resolve({version: version.version, path: 'mysqld'})
269+
resolve({version: version.version, path: 'mysqld', installedOnSystem: true})
270270
}
271271
}
272272
}
@@ -422,7 +422,7 @@ class Executor {
422422
this.logger.log('Finished writing init file')
423423
}
424424

425-
async startMySQL(options: InternalServerOptions, installedMySQLBinary: InstalledMySQLVersion): Promise<MySQLDB> {
425+
async startMySQL(options: InternalServerOptions, installedMySQLBinary: DownloadedMySQLVersion): Promise<MySQLDB> {
426426
this.version = installedMySQLBinary.version
427427
this.removeExitHandler = onExit(() => {
428428
if (options._DO_NOT_USE_cli) {

types/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ export type MySQLVersion = {
7373
url: string
7474
}
7575

76-
export type InstalledMySQLVersion = {
76+
export type DownloadedMySQLVersion = {
7777
version: string,
78-
path: string
78+
path: string,
79+
installedOnSystem: boolean
7980
}
8081

8182
export type BinaryInfo = {

0 commit comments

Comments
 (0)