Skip to content

Commit cc06485

Browse files
rename internal options
1 parent d1e4568 commit cc06485

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

src/constants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ export const DEFAULT_OPTIONS: InternalServerOptions = {
1515
lockRetries: 1_000,
1616
lockRetryWait: 1_000,
1717
username: 'root',
18-
deleteDBAfterStopped: true,
19-
//mysqlmsn = MySQL Memory Server Node.js
20-
dbPath: normalizePath(`${tmpdir()}/mysqlmsn/dbs/${randomUUID().replace(/-/g, '')}`),
2118
ignoreUnsupportedSystemVersion: false,
2219
port: 0,
2320
xPort: 0,
24-
binaryDirectoryPath: `${tmpdir()}/mysqlmsn/binaries`,
2521
downloadRetries: 10,
26-
initSQLString: ''
22+
initSQLString: '',
23+
_DO_NOT_USE_deleteDBAfterStopped: true,
24+
//mysqlmsn = MySQL Memory Server Node.js
25+
_DO_NOT_USE_dbPath: normalizePath(`${tmpdir()}/mysqlmsn/dbs/${randomUUID().replace(/-/g, '')}`),
26+
_DO_NOT_USE_binaryDirectoryPath: `${tmpdir()}/mysqlmsn/binaries`
2727
} as const;
2828

2929
export const LOG_LEVELS = {

src/libraries/Downloader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function extractBinary(url: string, archiveLocation: string, extractedLocation:
181181
export function downloadBinary(binaryInfo: BinaryInfo, options: InternalServerOptions, logger: Logger): Promise<string> {
182182
return new Promise(async (resolve, reject) => {
183183
const {url, version} = binaryInfo;
184-
const dirpath = options.binaryDirectoryPath
184+
const dirpath = options._DO_NOT_USE_binaryDirectoryPath
185185
logger.log('Binary path:', dirpath)
186186
await fsPromises.mkdir(dirpath, {recursive: true})
187187

src/libraries/Executor.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Executor {
9898
if (portIssue || xPortIssue) {
9999
this.logger.log('Error log when exiting for port in use error:', errorLog)
100100
try {
101-
await this.#deleteDatabaseDirectory(options.dbPath)
101+
await this.#deleteDatabaseDirectory(options._DO_NOT_USE_dbPath)
102102
} catch (e) {
103103
this.logger.error(e)
104104
return reject(`MySQL failed to listen on a certain port. To restart MySQL with a different port, the database directory needed to be deleted. An error occurred while deleting the database directory. Aborting. The error was: ${e}`)
@@ -107,7 +107,7 @@ class Executor {
107107
}
108108

109109
try {
110-
if (options.deleteDBAfterStopped) {
110+
if (options._DO_NOT_USE_deleteDBAfterStopped) {
111111
await this.#deleteDatabaseDirectory(dbPath)
112112
}
113113
} catch (e) {
@@ -400,15 +400,15 @@ class Executor {
400400

401401
this.logger.log('Writing init file')
402402

403-
await fsPromises.writeFile(`${options.dbPath}/init.sql`, initText, {encoding: 'utf8'})
403+
await fsPromises.writeFile(`${options._DO_NOT_USE_dbPath}/init.sql`, initText, {encoding: 'utf8'})
404404

405405
this.logger.log('Finished writing init file')
406406
}
407407

408408
async startMySQL(options: InternalServerOptions, binaryFilepath: string): Promise<MySQLDB> {
409409
let retries = 0;
410410

411-
const datadir = normalizePath(`${options.dbPath}/data`)
411+
const datadir = normalizePath(`${options._DO_NOT_USE_dbPath}/data`)
412412

413413
do {
414414
await this.#setupDataDirectories(options, binaryFilepath, datadir, true);
@@ -420,7 +420,7 @@ class Executor {
420420

421421
try {
422422
this.logger.log('Starting MySQL process')
423-
const resolved = await this.#startMySQLProcess(options, port, mySQLXPort, datadir, options.dbPath, binaryFilepath)
423+
const resolved = await this.#startMySQLProcess(options, port, mySQLXPort, datadir, options._DO_NOT_USE_dbPath, binaryFilepath)
424424
this.logger.log('Starting process was successful')
425425
return resolved
426426
} catch (e) {

stress-tests/stress.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ for (let i = 0; i < 100; i++) {
1818
const options: ServerOptions = {
1919
username: 'dbuser',
2020
logLevel: 'LOG',
21-
deleteDBAfterStopped: !process.env.useCIDBPath,
21+
_DO_NOT_USE_deleteDBAfterStopped: !process.env.useCIDBPath,
2222
ignoreUnsupportedSystemVersion: true
2323
}
2424

2525
if (process.env.useCIDBPath) {
26-
options.dbPath = `${dbPath}/${i}`
27-
options.binaryDirectoryPath = binaryPath
26+
options._DO_NOT_USE_dbPath = `${dbPath}/${i}`
27+
options._DO_NOT_USE_binaryDirectoryPath = binaryPath
2828
}
2929

3030
const db = await createDB(options)

tests/sql.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ beforeEach(async () => {
1818
const options: ServerOptions = {
1919
username: 'root',
2020
logLevel: 'LOG',
21-
deleteDBAfterStopped: !process.env.useCIDBPath,
21+
_DO_NOT_USE_deleteDBAfterStopped: !process.env.useCIDBPath,
2222
ignoreUnsupportedSystemVersion: true
2323
}
2424

2525
if (process.env.useCIDBPath) {
26-
options.dbPath = `${dbPath}/${randomUUID()}`
27-
options.binaryDirectoryPath = binaryPath
26+
options._DO_NOT_USE_dbPath = `${dbPath}/${randomUUID()}`
27+
options._DO_NOT_USE_binaryDirectoryPath = binaryPath
2828
}
2929

3030
db = await createDB(options)

types/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ export type InternalServerOptions = {
3030
lockRetries: number,
3131
lockRetryWait: number,
3232
username: string,
33-
deleteDBAfterStopped: boolean,
34-
dbPath: string,
3533
ignoreUnsupportedSystemVersion: boolean,
3634
port: number,
3735
xPort: number,
38-
binaryDirectoryPath: string,
3936
downloadRetries: number,
4037
initSQLString: string
38+
_DO_NOT_USE_deleteDBAfterStopped: boolean,
39+
_DO_NOT_USE_dbPath: string,
40+
_DO_NOT_USE_binaryDirectoryPath: string,
4141
}
4242

4343
export type ExecutorOptions = {

0 commit comments

Comments
 (0)