Skip to content

Commit 3daf254

Browse files
chore: change async main function in cli to sync function
1 parent 0b6f597 commit 3daf254

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/cli.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createDB } from "./index";
33
import { DEFAULT_OPTIONS_KEYS, OPTION_TYPE_CHECKS } from "./constants";
44
import { ServerOptions } from "../types";
55

6-
async function main() {
6+
function main() {
77
const definedOptions = process.argv.filter((option) => option.startsWith('--'))
88
const options: ServerOptions = {
99
_DO_NOT_USE_cli: true
@@ -44,17 +44,18 @@ async function main() {
4444
}
4545
}
4646
console.log('Creating ephemeral MySQL database...')
47-
const db = await createDB(options);
48-
console.log(`A MySQL database has been successfully created with the following parameters:\n\nMySQL Version: ${db.mysql.version} (${db.mysql.versionIsInstalledOnSystem ? 'installed on this system' : 'not installed on this system - downloaded from the MySQL CDN'}) \nUsername: ${db.username} \nDatabase Name: ${db.dbName} \nPort: ${db.port} \nX Plugin Port: ${db.xPort} \nSocket: ${db.socket} \nX Plugin Socket: ${db.xSocket}\n`)
49-
if (process.platform === 'win32') {
50-
//The connection information logs will be different for Windows compared to other platforms.
51-
//Windows uses mysqlsh instead of mysql to invoke the client shell, needs a --sql flag to be put into SQL mode, and also does not have a protocol flag.
52-
//Also according to https://bugs.mysql.com/bug.php?id=106852, you cannot log into a MySQL database with a named pipe for the first connection so a socket connection suggestion
53-
//should only be displayed for non-Windows platforms.
54-
console.log(`If you want to use the MySQL CLI client to connect to the database, you can use the following command: \nmysqlsh --sql -u ${db.username} -P ${db.port}\nIf prompted for a password, leave the password field blank. The database does not have a password set.`)
55-
} else {
56-
console.log(`If you want to use the MySQL CLI client to connect to the database, you can use either commands: \nmysql -u ${db.username} -P ${db.port} --protocol tcp \nOR\nmysql -u ${db.username} --socket ${db.socket}\nIf prompted for a password, leave the password field blank. The database does not have a password set.`)
57-
}
47+
createDB(options).then(db => {
48+
console.log(`A MySQL database has been successfully created with the following parameters:\n\nMySQL Version: ${db.mysql.version} (${db.mysql.versionIsInstalledOnSystem ? 'installed on this system' : 'not installed on this system - downloaded from the MySQL CDN'}) \nUsername: ${db.username} \nDatabase Name: ${db.dbName} \nPort: ${db.port} \nX Plugin Port: ${db.xPort} \nSocket: ${db.socket} \nX Plugin Socket: ${db.xSocket}\n`)
49+
if (process.platform === 'win32') {
50+
//The connection information logs will be different for Windows compared to other platforms.
51+
//Windows uses mysqlsh instead of mysql to invoke the client shell, needs a --sql flag to be put into SQL mode, and also does not have a protocol flag.
52+
//Also according to https://bugs.mysql.com/bug.php?id=106852, you cannot log into a MySQL database with a named pipe for the first connection so a socket connection suggestion
53+
//should only be displayed for non-Windows platforms.
54+
console.log(`If you want to use the MySQL CLI client to connect to the database, you can use the following command: \nmysqlsh --sql -u ${db.username} -P ${db.port}\nIf prompted for a password, leave the password field blank. The database does not have a password set.`)
55+
} else {
56+
console.log(`If you want to use the MySQL CLI client to connect to the database, you can use either commands: \nmysql -u ${db.username} -P ${db.port} --protocol tcp \nOR\nmysql -u ${db.username} --socket ${db.socket}\nIf prompted for a password, leave the password field blank. The database does not have a password set.`)
57+
}
58+
})
5859
}
5960

6061
main()

0 commit comments

Comments
 (0)